Created
December 13, 2011 19:34
-
-
Save Raynos/1473536 to your computer and use it in GitHub Desktop.
Revisions
-
Raynos revised this gist
Mar 3, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ function iterativelyWalk(nodes, cb) { } if (node.childNodes.length) { nodes = slice.call(node.childNodes).concat(nodes) } } } -
Raynos revised this gist
Mar 3, 2012 . 1 changed file with 15 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,18 @@ var slice = Array.prototype.slice function iterativelyWalk(nodes, cb) { nodes = slice.call(nodes) while(nodes.length) { var node = nodes.shift(), ret = cb(node) if (ret) { return ret } if (node.childNodes.length) { nodes = slice.call(node.childNodes).concat(nodes); } } } -
Raynos revised this gist
Mar 3, 2012 . 1 changed file with 3 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,15 @@ function walk(nodes, cb) { var node, last, ret, i = 0 while (node = nodes[i++]) { do { ret = cb(node) if (ret) { return ret } } while (node = node.firstChild) } } -
Raynos revised this gist
Mar 3, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ function walk(nodes, cb) { do { ret = cb(node) if (ret) { return ret } } while (node = node.firstChild) node = last -
Raynos revised this gist
Mar 3, 2012 . 2 changed files with 25 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ function walk(nodes, cb) { var node = nodes[0], last, ret, i = 0 do { last = node do { ret = cb(node) if (ret) { return ret; } } while (node = node.firstChild) node = last } while (node = nodes[++i]) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,16 @@ function recursivelyWalk(nodes, cb) { for (var i = 0, len = nodes.length; i < len; i++) { var node = nodes[i], ret = cb(node) if (ret) { return ret } if (node.childNodes.length) { var ret = recursivelyWalk(node.childNodes, cb) if (ret) { return ret } } } -
Raynos created this gist
Dec 13, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ function recursivelyWalk(nodes, cb) { for (var i = 0, len = nodes.length; i < len; i++) { var node = nodes[i]; var ret = cb(node); if (ret) { return ret; } if (node.childNodes && node.childNodes.length) { var ret = recursivelyWalk(node.childNodes, cb); if (ret) { return ret; } } } }