From 50a76844b844f70f4b4f5d5f95e46420d1a9d218 Mon Sep 17 00:00:00 2001 From: Rafael Weinstein Date: Thu, 16 Jan 2014 16:00:16 -0800 Subject: [PATCH] Force all expressions to reset deps on changes. This is required with the current approach because path objects may become reachable. See: https://github.com/Polymer/polymer-expressions/issues/21 R=arv BUG= Review URL: https://codereview.appspot.com/53530043 --- src/polymer-expressions.js | 9 ++++++--- tests/tests.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/polymer-expressions.js b/src/polymer-expressions.js index 3f68492..1a28212 100644 --- a/src/polymer-expressions.js +++ b/src/polymer-expressions.js @@ -389,13 +389,16 @@ var self = this; function valueFn() { - if (self.dynamicDeps) + // TODO(rafaelw): + // https://github.com/Polymer/polymer-expressions/issues/21 + var updateObserver = true; //self.dynamicDeps; + if (updateObserver) observer.startReset(); var value = self.getValue(model, - self.dynamicDeps ? observer : undefined, + updateObserver ? observer : undefined, filterRegistry); - if (self.dynamicDeps) + if (updateObserver) observer.finishReset(); return value; diff --git a/tests/tests.js b/tests/tests.js index e40df6a..adae2bf 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -969,6 +969,35 @@ suite('PolymerExpressions', function() { }); }); + test('computed - newly reachable objects', function(done) { + var div = createTestHtml( + ''); + + var model = {}; + + recursivelySetTemplateModel(div, model); + + then(function() { + assert.equal('false', div.childNodes[1].getAttribute('foo')); + model.foo = {}; + + }).then(function() { + assert.equal('false', div.childNodes[1].getAttribute('foo')); + model.foo.bar = {}; + + }).then(function() { + assert.equal('false', div.childNodes[1].getAttribute('foo')); + model.foo.bar.bat = 1; + + }).then(function() { + assert.equal('true', div.childNodes[1].getAttribute('foo')); + + done(); + }); + }); + test('computed property with ident index', function(done) { var div = createTestHtml(