Skip to content

Commit

Permalink
temporary hack to fix unparser bug // aurelia/binding#586
Browse files Browse the repository at this point in the history
  • Loading branch information
3cp committed Apr 7, 2017
1 parent 04f0ac8 commit 3142b0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
17 changes: 15 additions & 2 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,21 @@ export class Parser {
input = input || '';
const rejectAssignment = opts.rejectAssignment || false;

return this.cache[input]
|| (this.cache[input] = new ParserImplementation(this.lexer, input, {rejectAssignment}).parseExpression());
if (!this.cache[input]) {
const parserImp = new ParserImplementation(this.lexer, input, {rejectAssignment});
this.cache[input] = parserImp.parseExpression();

let exp = '';
for (let i = 0, length = parserImp.tokens.length; i < length; ++i) {
exp += parserImp.tokens[i].text;
}

this.cache[input].toString = function() {
return exp;
};
}

return this.cache[input];
}
}

Expand Down
7 changes: 4 additions & 3 deletions test/unparser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ test('Unparser: should unparse', t => {
'[a,b,c]',
'foo',
// https://github.com/aurelia/binding/issues/586
// 'a&&(b||c)',
// 'a&&(b=1)',
// '2*(2+3)',
'a&&(b||c)',
'a&&(b=1)',
'2*(2+3)',
'!(true?true:true)',
];
let i = expressions.length;
while (i--) {
Expand Down

0 comments on commit 3142b0a

Please sign in to comment.