diff --git a/lib/elements/dom-bind.html b/lib/elements/dom-bind.html
index 436791d85c..19497e0d32 100644
--- a/lib/elements/dom-bind.html
+++ b/lib/elements/dom-bind.html
@@ -103,7 +103,7 @@
for (let n=this.root.firstChild; n; n=n.nextSibling) {
this.__children[this.__children.length] = n;
}
- this._flushProperties();
+ this._enableProperties();
}
this.__insertChildren();
this.dispatchEvent(new CustomEvent('dom-change', {
diff --git a/lib/mixins/element-mixin.html b/lib/mixins/element-mixin.html
index 9465d1d034..41d7551767 100644
--- a/lib/mixins/element-mixin.html
+++ b/lib/mixins/element-mixin.html
@@ -631,9 +631,7 @@
if (window.ShadyCSS && this._template) {
window.ShadyCSS.styleElement(this);
}
- if (!this.__dataInitialized) {
- this._flushProperties();
- }
+ this._enableProperties();
}
/**
diff --git a/lib/mixins/property-accessors.html b/lib/mixins/property-accessors.html
index a586f31a2d..7104d229f8 100644
--- a/lib/mixins/property-accessors.html
+++ b/lib/mixins/property-accessors.html
@@ -475,6 +475,18 @@
}
}
+ // TODO(kschaaf): document.
+ _enableProperties() {
+ if (!this.__dataPropertiesEnabled) {
+ this.__dataPropertiesEnabled = true;
+ if (this.__dataInstanceProps) {
+ this._initializeInstanceProperties(this.__dataInstanceProps);
+ this.__dataInstanceProps = null;
+ }
+ this.ready()
+ }
+ }
+
/**
* Calls the `_propertiesChanged` callback with the current set of
* pending changes (and old values recorded when pending changes were
@@ -487,9 +499,7 @@
* @protected
*/
_flushProperties() {
- if (!this.__dataInitialized) {
- this.ready()
- } else if (this.__dataPending) {
+ if (this.__dataPending) {
let changedProps = this.__dataPending;
this.__dataPending = null;
this.__dataCounter++;
@@ -513,12 +523,6 @@
* @public
*/
ready() {
- // Update instance properties that shadowed proto accessors; these take
- // priority over any defaults set in constructor or attributeChangedCallback
- if (this.__dataInstanceProps) {
- this._initializeInstanceProperties(this.__dataInstanceProps);
- this.__dataInstanceProps = null;
- }
this.__dataInitialized = true;
// Run normal flush
this._flushProperties();
diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html
index b45e7453b9..4bb5ea43b4 100644
--- a/lib/mixins/property-effects.html
+++ b/lib/mixins/property-effects.html
@@ -230,9 +230,8 @@
// And the host has already initialized clients; this prevents
// an issue with a host observing data changes before clients are ready.
let host;
- if (notified && (host = inst.__dataHost) && host._flushProperties
- && host.__dataClientsInitialized) {
- host._flushProperties();
+ if (notified && (host = inst.__dataHost) && host._invalidateProperties) {
+ host._invalidateProperties();
}
}
@@ -1430,6 +1429,7 @@
*/
_flushClients() {
if (!this.__dataClientsInitialized) {
+ this.__dataClientsInitialized = true;
this._readyClients();
}
// Flush all clients
@@ -1438,7 +1438,10 @@
this.__dataPendingClients = null;
for (let i=0; i < clients.length; i++) {
let client = clients[i];
- if (!client.__dataInitialized || client.__dataPending) {
+ // boot up client if necessary, otherwise flush properties
+ if (!client.__dataPropertiesEnabled) {
+ client._enableProperties();
+ } else if (client.__dataPending) {
client._flushProperties();
}
}
@@ -1479,9 +1482,9 @@
* @override
*/
ready() {
- super.ready();
+ this._flushProperties();
if (!this.__dataClientsInitialized) {
- this._readyClients();
+ this._flushClients();
}
// Before ready, client notifications do not trigger _flushProperties.
// Therefore a flush is necessary here if data has been set.
@@ -1498,7 +1501,7 @@
* @protected
*/
_readyClients() {
- this.__dataClientsInitialized = true;
+ this.__dataInitialized = true;
}
/**
diff --git a/lib/utils/templatize.html b/lib/utils/templatize.html
index 456c01510f..31f792ec55 100644
--- a/lib/utils/templatize.html
+++ b/lib/utils/templatize.html
@@ -63,7 +63,7 @@
// or when there isn't instance props.
let options = this.__templatizeOptions;
if ((props && options.instanceProps) || !options.instanceProps) {
- this._flushProperties();
+ this._enableProperties();
}
}
/**
@@ -251,7 +251,7 @@
template.__dataTemp = {};
template.__dataPending = null;
template.__dataOld = null;
- template._flushProperties();
+ template._enableProperties();
}
}
diff --git a/test/unit/property-accessors.html b/test/unit/property-accessors.html
index 9fb9a4f61c..8af5eeb265 100644
--- a/test/unit/property-accessors.html
+++ b/test/unit/property-accessors.html
@@ -29,7 +29,7 @@
this._propertiesChanged = sinon.spy();
}
connectedCallback() {
- this._flushProperties();
+ this._enableProperties();
}
}
XFoo.createPropertiesForAttributes();
diff --git a/test/unit/property-effects.html b/test/unit/property-effects.html
index c1be29da2d..b236897d5b 100644
--- a/test/unit/property-effects.html
+++ b/test/unit/property-effects.html
@@ -1514,7 +1514,7 @@
BaseClass = class extends Polymer.PropertyEffects(HTMLElement) {
connectedCallback() {
this.pcSpy = sinon.spy();
- this._flushProperties();
+ this._enableProperties();
}
_propertiesChanged(props, changedProps, oldProps) {
this.pcSpy(props, changedProps, oldProps);