Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Treat numbers as numbers in expressions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
arv committed Mar 25, 2014
1 parent 16291cd commit 3978609
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/polymer-expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,10 @@
case 'true':
return true;
}

if (!isNaN(Number(name)))
return true;

return false;
};

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3978609

Please sign in to comment.