Skip to content

Commit 22d27aa

Browse files
author
Steven Orvell
committed
Fixes #4650: if an observed path changes, the repeat should render but in addition, the path should be notified. This is necessary since “mutableData” is optional.
1 parent 07dd436 commit 22d27aa

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

lib/elements/dom-repeat.html

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -610,18 +610,20 @@
610610
// If path was index into array...
611611
if (itemsIdx == parseInt(itemsIdx, 10)) {
612612
let itemSubPath = dot < 0 ? '' : itemsPath.substring(dot+1);
613-
// See if the item subpath should trigger a full refresh...
614-
if (!this.__handleObservedPaths(itemSubPath)) {
615-
// If not, forward to the instance for that index
616-
let instIdx = this.__itemsIdxToInstIdx[itemsIdx];
617-
let inst = this.__instances[instIdx];
618-
if (inst) {
619-
let itemPath = this.as + (itemSubPath ? '.' + itemSubPath : '');
620-
// This is effectively `notifyPath`, but avoids some of the overhead
621-
// of the public API
622-
inst._setPendingPropertyOrPath(itemPath, value, false, true);
623-
inst._flushProperties();
624-
}
613+
// If the path is observed, it will trigger a full refresh
614+
this.__handleObservedPaths(itemSubPath)
615+
// Note, even if a rull refresh is triggered, always do the path
616+
// notification because unless mutableData is used for dom-repeat
617+
// and all elements in the instance subtree, a full refresh may
618+
// not trigger the proper update.
619+
let instIdx = this.__itemsIdxToInstIdx[itemsIdx];
620+
let inst = this.__instances[instIdx];
621+
if (inst) {
622+
let itemPath = this.as + (itemSubPath ? '.' + itemSubPath : '');
623+
// This is effectively `notifyPath`, but avoids some of the overhead
624+
// of the public API
625+
inst._setPendingPropertyOrPath(itemPath, value, false, true);
626+
inst._flushProperties();
625627
}
626628
return true;
627629
}

test/unit/dom-repeat.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4088,6 +4088,24 @@ <h4>x-repeat-chunked</h4>
40884088
assert(stamped[0].classList.contains('x-simple-repeat'), 'expected scoping');
40894089
});
40904090

4091+
test('paths update on observed properties', function() {
4092+
let simple = fixture('simple');
4093+
Polymer.flush();
4094+
//debugger;
4095+
var stamped = simple.root.querySelectorAll('*:not(template):not(dom-repeat)');
4096+
assert.equal(stamped[0].itemaProp, 'prop-1');
4097+
simple.$.repeat.observe = 'prop';
4098+
Polymer.flush();
4099+
simple.set('items.0.prop', {foo: 0});
4100+
Polymer.flush();
4101+
assert.equal(stamped[0].get('itemaProp.foo'), 0);
4102+
simple.set('items.0.prop.foo', 1);
4103+
Polymer.flush();
4104+
assert.equal(stamped[0].get('itemaProp.foo'), 1);
4105+
simple.set('items.0.prop.foo', 2);
4106+
Polymer.flush();
4107+
assert.equal(stamped[0].get('itemaProp.foo'), 2);
4108+
});
40914109
});
40924110

40934111
suite('timing', function() {

0 commit comments

Comments
 (0)