diff --git a/src/polymer-expressions.js b/src/polymer-expressions.js index d5a1df9..7489ef7 100644 --- a/src/polymer-expressions.js +++ b/src/polymer-expressions.js @@ -125,11 +125,17 @@ return binding; } + // TODO(rafaelw): Implement simple LRU. + var expressionParseCache = {}; + function getExpressionBinding(model, expressionText) { try { - // TODO(rafaelw): Cache expressions. - var delegate = new ASTDelegate(); - esprima.parse(expressionText, delegate); + var delegate = expressionParseCache[expressionText]; + if (!delegate) { + delegate = new ASTDelegate(); + esprima.parse(expressionText, delegate); + expressionParseCache[expressionText] = delegate; + } if (!delegate.expression && !delegate.labeledStatements.length) return;