domutils
Advanced tools
Comparing version 1.6.2 to 1.7.0
@@ -85,16 +85,12 @@ var isTag = require("domelementtype").isTag; | ||
var result = []; | ||
var stack = [rootElems]; | ||
var stack = rootElems.slice(); | ||
while(stack.length){ | ||
var elems = stack.pop(); | ||
for(var i = 0, j = elems.length; i < j; i++){ | ||
if(!isTag(elems[i])) continue; | ||
if(test(elems[i])) result.push(elems[i]); | ||
var elem = stack.shift(); | ||
if(!isTag(elem)) continue; | ||
if (elem.children && elem.children.length > 0) { | ||
stack.unshift.apply(stack, elem.children); | ||
} | ||
while(j-- > 0){ | ||
if(elems[j].children && elems[j].children.length > 0){ | ||
stack.push(elems[j].children); | ||
} | ||
} | ||
if(test(elem)) result.push(elem); | ||
} | ||
return result; | ||
} |
{ | ||
"name": "domutils", | ||
"version": "1.6.2", | ||
"version": "1.7.0", | ||
"description": "utilities for working with htmlparser2's dom", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
20546
16
606