min-document
Advanced tools
Comparing version 2.8.1 to 2.9.0
@@ -0,1 +1,3 @@ | ||
var domWalk = require("dom-walk") | ||
var DOMText = require("./dom-text.js") | ||
@@ -72,18 +74,13 @@ var DOMElement = require("./dom-element.js") | ||
if (parent.className === classNames) { | ||
return [parent] | ||
} | ||
var elems = [] | ||
var arr = parent.childNodes | ||
var result = null | ||
domWalk(parent, function (node) { | ||
var classes = node.className.split(" ") | ||
if (!arr) { | ||
return result | ||
} | ||
if (classes.indexOf(classNames) !== -1) { | ||
elems.push(node) | ||
} | ||
}) | ||
for (var i = 0, len = arr.length; !result && i < len; i++) { | ||
result = getElementsByClassName(classNames, arr[i]) | ||
} | ||
return result | ||
return elems | ||
} |
{ | ||
"name": "min-document", | ||
"version": "2.8.1", | ||
"version": "2.9.0", | ||
"description": "A minimal DOM implementation", | ||
@@ -19,3 +19,5 @@ "keywords": [], | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"dom-walk": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
@@ -22,0 +24,0 @@ "run-browser": "git://github.com/Raynos/run-browser", |
@@ -128,2 +128,18 @@ var test = require("tape") | ||
test("can getElementsByClassName for many elements", function (assert) { | ||
function h(className) { | ||
var div = document.createElement("div") | ||
div.className = className | ||
return div | ||
} | ||
document.body.appendChild(h("multi-class-bar")) | ||
document.body.appendChild(h("multi-class-bar")) | ||
var elems = document.getElementsByClassName("multi-class-bar") | ||
assert.equal(elems.length, 2) | ||
assert.end() | ||
}) | ||
test("can create/manipulate textnodes", function (assert) { | ||
@@ -130,0 +146,0 @@ var textnode = document.createTextNode("hello") |
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
29691
617
1
+ Addeddom-walk@^0.1.0
+ Addeddom-walk@0.1.2(transitive)