From 06df53d99816b5a7dae650715d3f021cc4a21240 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 17 May 2017 17:00:33 -0700 Subject: [PATCH] Fixes #4601. Client elements can be readied that have already enabled properties. This can happen when templatize is used to create instances with no properties. In this case, in order for properties to flush properly to clients, clients must be flushed. --- lib/mixins/property-effects.html | 2 ++ test/unit/templatize.html | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 59ef27e49e..109ce3d873 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -1466,6 +1466,8 @@ let client = clients[i]; if (!client.__dataEnabled) { client._enableProperties(); + } else { + client._flushProperties(); } } } diff --git a/test/unit/templatize.html b/test/unit/templatize.html index 5cbb44d0a6..df7be63f41 100644 --- a/test/unit/templatize.html +++ b/test/unit/templatize.html @@ -181,6 +181,20 @@ assert.isUndefined(childB.computedFromLiteral); }); + test('templatize with no props, instance manually flushes', function() { + let templatizeA = host.shadowRoot.querySelector('[id=templatizeA]'); + templatizeA.go(false); + let childA = host.shadowRoot.querySelector('#childA'); + assert.ok(childA); + sinon.spy(childA, 'objChanged'); + assert.isUndefined(childA.obj); + let o = {foo: true}; + templatizeA.instance._setPendingProperty('obj', o); + templatizeA.instance._flushProperties(); + assert.equal(childA.obj, o); + assert.isTrue(childA.objChanged.calledOnce); + }); + }); suite('templatizer behavior', function() {