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

Commit

Permalink
Force all expressions to reset deps on changes.
Browse files Browse the repository at this point in the history
This is required with the current approach because path objects may become reachable.

See: #21

R=arv
BUG=

Review URL: https://codereview.appspot.com/53530043
  • Loading branch information
rafaelw committed Jan 17, 2014
1 parent 080d12f commit 50a7684
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/polymer-expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 29 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,35 @@ suite('PolymerExpressions', function() {
});
});

test('computed - newly reachable objects', function(done) {
var div = createTestHtml(
'<template bind>' +
'<div foo="{{ 1 == foo.bar.bat }}">' +
'</template>');

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(
Expand Down

0 comments on commit 50a7684

Please sign in to comment.