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

Commit

Permalink
If the path is true, false or null don't treat that as simple path
Browse files Browse the repository at this point in the history
This is so that `{{ true }}` is treated as true and not as `model.true`.

Fixes #24
  • Loading branch information
arv committed Mar 25, 2014
1 parent 257a128 commit 1483676
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/polymer-expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,16 @@
}
}

function isLiteralExpression(name) {
switch (name) {
case 'false':
case 'null':
case 'true':
return true;
}
return false;
};

function PolymerExpressions() {}

PolymerExpressions.prototype = {
Expand Down Expand Up @@ -630,16 +640,18 @@

if (path.valid) {
if (path.length == 1) {
return function(model, node, oneTime) {
if (oneTime)
return path.getValueFrom(model);

var scope = findScope(model, path[0]);
return new PathObserver(scope, path);
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; // bail out early if pathString is simple path.
}

return prepareBinding(pathString, name, node, this);
Expand Down

0 comments on commit 1483676

Please sign in to comment.