min-document
Advanced tools
Comparing version 0.2.4 to 0.2.6
27
index.js
@@ -50,2 +50,22 @@ function DOMText(value) { | ||
function DocumentFragment() { | ||
this.childNodes = [] | ||
this.parentNode = null | ||
} | ||
DocumentFragment.prototype.type = "DocumentFragment" | ||
DocumentFragment.prototype.nodeType = 11 | ||
DocumentFragment.prototype.nodeName = "#document-fragment" | ||
DocumentFragment.prototype.appendChild = DOMElement.prototype.appendChild | ||
DocumentFragment.prototype.replaceChild = DOMElement.prototype.replaceChild | ||
DocumentFragment.prototype.removeChild = DOMElement.prototype.removeChild | ||
DocumentFragment.prototype.toString = | ||
function _DocumentFragment_toString() { | ||
return this.childNodes.map(function (node) { | ||
return String(node) | ||
}).join("") | ||
} | ||
module.exports = Document() | ||
@@ -56,3 +76,4 @@ | ||
createTextNode: createTextNode, | ||
createElement: createElement | ||
createElement: createElement, | ||
createDocumentFragment: createDocumentFragment | ||
} | ||
@@ -69,2 +90,6 @@ } | ||
function createDocumentFragment() { | ||
return new DocumentFragment() | ||
} | ||
function _Element_toString() { | ||
@@ -71,0 +96,0 @@ var strings = [] |
{ | ||
"name": "min-document", | ||
"version": "0.2.4", | ||
"version": "0.2.6", | ||
"description": "A minimal DOM implementation", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -8,2 +8,4 @@ var test = require("tape") | ||
assert.equal(typeof document.createElement, "function") | ||
assert.equal(typeof document.createDocumentFragment, "function") | ||
assert.end() | ||
@@ -27,1 +29,26 @@ }) | ||
}) | ||
test("can createDocumentFragment", function (assert) { | ||
var frag = document.createDocumentFragment() | ||
var h1 = document.createElement("h1") | ||
var h2 = document.createElement("h2") | ||
frag.appendChild(h1) | ||
assert.equal(String(frag), "<h1>\n</h1>") | ||
frag.appendChild(h2) | ||
assert.equal(String(frag), "<h1>\n</h1><h2>\n</h2>") | ||
frag.removeChild(h1) | ||
assert.equal(String(frag), "<h2>\n</h2>") | ||
frag.replaceChild(h1, h2) | ||
assert.equal(String(frag), "<h1>\n</h1>") | ||
assert.end() | ||
}) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10272
218