Skip to content

Commit

Permalink
Fixes #4601. Client elements can be readied that have already enabled…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
Steven Orvell committed May 18, 2017
1 parent c4e516f commit 06df53d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/mixins/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,8 @@
let client = clients[i];
if (!client.__dataEnabled) {
client._enableProperties();
} else {
client._flushProperties();
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions test/unit/templatize.html
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 06df53d

Please sign in to comment.