Skip to content

Commit

Permalink
Fixes #4650: if an observed path changes, the repeat should render bu…
Browse files Browse the repository at this point in the history
…t in addition, the path should be notified. This is necessary since “mutableData” is optional.
  • Loading branch information
Steven Orvell committed Jun 8, 2017
1 parent 07dd436 commit 22d27aa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/elements/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -610,18 +610,20 @@
// If path was index into array...
if (itemsIdx == parseInt(itemsIdx, 10)) {
let itemSubPath = dot < 0 ? '' : itemsPath.substring(dot+1);
// See if the item subpath should trigger a full refresh...
if (!this.__handleObservedPaths(itemSubPath)) {
// If not, forward to the instance for that index
let instIdx = this.__itemsIdxToInstIdx[itemsIdx];
let inst = this.__instances[instIdx];
if (inst) {
let itemPath = this.as + (itemSubPath ? '.' + itemSubPath : '');
// This is effectively `notifyPath`, but avoids some of the overhead
// of the public API
inst._setPendingPropertyOrPath(itemPath, value, false, true);
inst._flushProperties();
}
// If the path is observed, it will trigger a full refresh
this.__handleObservedPaths(itemSubPath)
// Note, even if a rull refresh is triggered, always do the path
// notification because unless mutableData is used for dom-repeat
// and all elements in the instance subtree, a full refresh may
// not trigger the proper update.
let instIdx = this.__itemsIdxToInstIdx[itemsIdx];
let inst = this.__instances[instIdx];
if (inst) {
let itemPath = this.as + (itemSubPath ? '.' + itemSubPath : '');
// This is effectively `notifyPath`, but avoids some of the overhead
// of the public API
inst._setPendingPropertyOrPath(itemPath, value, false, true);
inst._flushProperties();
}
return true;
}
Expand Down
18 changes: 18 additions & 0 deletions test/unit/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -4088,6 +4088,24 @@ <h4>x-repeat-chunked</h4>
assert(stamped[0].classList.contains('x-simple-repeat'), 'expected scoping');
});

test('paths update on observed properties', function() {
let simple = fixture('simple');
Polymer.flush();
//debugger;
var stamped = simple.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped[0].itemaProp, 'prop-1');
simple.$.repeat.observe = 'prop';
Polymer.flush();
simple.set('items.0.prop', {foo: 0});
Polymer.flush();
assert.equal(stamped[0].get('itemaProp.foo'), 0);
simple.set('items.0.prop.foo', 1);
Polymer.flush();
assert.equal(stamped[0].get('itemaProp.foo'), 1);
simple.set('items.0.prop.foo', 2);
Polymer.flush();
assert.equal(stamped[0].get('itemaProp.foo'), 2);
});
});

suite('timing', function() {
Expand Down

0 comments on commit 22d27aa

Please sign in to comment.