From 3978609509b8b2399c0561ba899eb9807c6cb465 Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Tue, 25 Mar 2014 19:24:18 -0400 Subject: [PATCH] Treat numbers as numbers in expressions This is so that `{{ 1 }} ` is treated as `1` and not as `model.1`. Same goes for `{{ 1.2 }}` which should not be treated as `model.1.2`. Fixes #24 --- src/polymer-expressions.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/polymer-expressions.js b/src/polymer-expressions.js index e1aac2c..4c4fdce 100644 --- a/src/polymer-expressions.js +++ b/src/polymer-expressions.js @@ -592,6 +592,10 @@ case 'true': return true; } + + if (!isNaN(Number(name))) + return true; + return false; }; @@ -638,20 +642,17 @@ return prepareEventBinding(path, name, this); } - if (path.valid) { + if (!isLiteralExpression(pathString) && path.valid) { if (path.length == 1) { - if (!isLiteralExpression(path[0])) { - return function(model, node, oneTime) { - if (oneTime) - return path.getValueFrom(model); - - var scope = findScope(model, path[0]); - return new PathObserver(scope, path); - }; - } - } else { - return; // bail out early if pathString is simple path. + return function(model, node, oneTime) { + if (oneTime) + return path.getValueFrom(model); + + var scope = findScope(model, path[0]); + return new PathObserver(scope, path); + }; } + return; // bail out early if pathString is simple path. } return prepareBinding(pathString, name, node, this);