From 22d27aa087f43338c9b413d2ae3a866fcc84f34c Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 7 Jun 2017 17:50:27 -0700 Subject: [PATCH] =?UTF-8?q?Fixes=20#4650:=20if=20an=20observed=20path=20ch?= =?UTF-8?q?anges,=20the=20repeat=20should=20render=20but=20in=20addition,?= =?UTF-8?q?=20the=20path=20should=20be=20notified.=20This=20is=20necessary?= =?UTF-8?q?=20since=20=E2=80=9CmutableData=E2=80=9D=20is=20optional.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/elements/dom-repeat.html | 26 ++++++++++++++------------ test/unit/dom-repeat.html | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/lib/elements/dom-repeat.html b/lib/elements/dom-repeat.html index f08249c905..81c841caba 100644 --- a/lib/elements/dom-repeat.html +++ b/lib/elements/dom-repeat.html @@ -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; } diff --git a/test/unit/dom-repeat.html b/test/unit/dom-repeat.html index 79176432f9..9d5cc2ba92 100644 --- a/test/unit/dom-repeat.html +++ b/test/unit/dom-repeat.html @@ -4088,6 +4088,24 @@

x-repeat-chunked

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() {