Skip to content

dom-repat: set path when an observed path changes. #4676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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