Skip to content

Commit

Permalink
[token] make parent and source non-enumerable
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgenEvens committed Feb 13, 2019
1 parent 8c0f245 commit 92f82c6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class Token {
Object.assign(this, options);
this.type_id = type;
this.type = NAMES[type];
this.parent = undefined;
this.source = undefined;
this.children = [];

this.start = start;
Expand All @@ -98,6 +96,22 @@ class Token {
this.closing = undefined; // Used by TAG_CONTROL to indicate a closing tag
this.value = undefined; // Used to store parsed values of expressions.
this.expr = undefined; // Used to hold the specific expressions on EXPRESSION node.

Object.defineProperty(this, 'source', {
value: undefined,
enumerable: false,
writable: true
});

Object.defineProperty(this, 'parent', {
value: undefined,
enumerable: false,
writable: true
});
}

get match() {
return this.source.substr(this.start, this.end - this.start + 1);
}

is(type) {
Expand Down

0 comments on commit 92f82c6

Please sign in to comment.