summaryrefslogtreecommitdiff
path: root/js/lib/node.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/node.js')
-rw-r--r--js/lib/node.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/js/lib/node.js b/js/lib/node.js
index 84fb122..9dc7c3f 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,7 +50,15 @@ NodeWalker.prototype.next = function(){
return {entering: entering, node: cur};
};
-function Node(nodeType, sourcepos) {
+var NodeWalker = function(root) {
+ return { current: root,
+ root: root,
+ entering: true,
+ next: next,
+ resumeAt: resumeAt };
+};
+
+var Node = function(nodeType, sourcepos) {
this.t = nodeType;
this.parent = null;
this.firstChild = null;
@@ -77,7 +79,7 @@ function Node(nodeType, sourcepos) {
this.fence_length = undefined;
this.fence_offset = undefined;
this.level = undefined;
-}
+};
Node.prototype.isContainer = function() {
return isContainer(this);
@@ -154,7 +156,7 @@ Node.prototype.insertBefore = function(sibling) {
};
Node.prototype.walker = function() {
- var walker = new NodeWalker(this);
+ var walker = NodeWalker(this);
return walker;
};