diff --git a/src/polymer-expressions.js b/src/polymer-expressions.js index 3f20943..c5faaaf 100644 --- a/src/polymer-expressions.js +++ b/src/polymer-expressions.js @@ -286,6 +286,21 @@ left = getFn(left); right = getFn(right); + switch (op) { + case '||': + this.dynamicDeps = true; + return function(model, observer, filterRegistry) { + return left(model, observer, filterRegistry) || + right(model, observer, filterRegistry); + }; + case '&&': + this.dynamicDeps = true; + return function(model, observer, filterRegistry) { + return left(model, observer, filterRegistry) && + right(model, observer, filterRegistry); + }; + } + return function(model, observer, filterRegistry) { return binaryOperators[op](left(model, observer, filterRegistry), right(model, observer, filterRegistry)); @@ -297,6 +312,8 @@ consequent = getFn(consequent); alternate = getFn(alternate); + this.dynamicDeps = true; + return function(model, observer, filterRegistry) { return test(model, observer, filterRegistry) ? consequent(model, observer, filterRegistry) : diff --git a/tests/tests.js b/tests/tests.js index 2e417ec..ec59a47 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -749,6 +749,44 @@ suite('PolymerExpressions', function() { }); }); + test('Expressions Conditional 2', function(done) { + var div = createTestHtml( + ''); + var model = { + checked: false, + a: 'A', + b: 'B' + }; + + recursivelySetTemplateModel(div, model); + + then(function() { + assert.strictEqual('B', div.childNodes[1].textContent); + + model.checked = true; + + }).then(function() { + assert.strictEqual('A', div.childNodes[1].textContent); + + model.a = 'AAA'; + }).then(function() { + assert.strictEqual('AAA', div.childNodes[1].textContent); + + model.checked = false; + + }).then(function() { + assert.strictEqual('B', div.childNodes[1].textContent); + + model.b = 'BBB'; + }).then(function() { + assert.strictEqual('BBB', div.childNodes[1].textContent); + + done(); + }); + }); + test('Expressions Literals', function(done) { var div = createTestHtml( '