diff options
Diffstat (limited to 'js/lib')
-rw-r--r-- | js/lib/node.js | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/js/lib/node.js b/js/lib/node.js index 84fb122..837f596 100644 --- a/js/lib/node.js +++ b/js/lib/node.js @@ -14,18 +14,12 @@ function isContainer(node) { t === 'Image'); } -function NodeWalker(root) { - this.current = root; - this.root = root; - this.entering = true; -} - -NodeWalker.prototype.resumeAt = function(node, entering) { +var resumeAt = function(node, entering) { this.current = node; this.entering = (entering === true); }; -NodeWalker.prototype.next = function(){ +var next = function(){ var cur = this.current; var entering = this.entering; @@ -56,6 +50,14 @@ NodeWalker.prototype.next = function(){ return {entering: entering, node: cur}; }; +var NodeWalker = function(root) { + return { current: root, + root: root, + entering: true, + next: next, + resumeAt: resumeAt }; +} + function Node(nodeType, sourcepos) { this.t = nodeType; this.parent = null; @@ -154,7 +156,7 @@ Node.prototype.insertBefore = function(sibling) { }; Node.prototype.walker = function() { - var walker = new NodeWalker(this); + var walker = NodeWalker(this); return walker; }; |