Skip to content

Commit 4eb252f

Browse files
author
Steven Orvell
committed
Docs and slight renaming.
1 parent 1f83fd7 commit 4eb252f

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

lib/mixins/property-accessors.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
_initializeProperties() {
138138
this.__serializing = false;
139139
this.__dataCounter = 0;
140+
this.__dataEnabled = false;
140141
this.__dataInitialized = false;
141142
this.__dataInvalid = false;
142143
// initialize data with prototype values saved when creating accessors
@@ -475,10 +476,16 @@
475476
}
476477
}
477478

478-
// TODO(kschaaf): document.
479+
/**
480+
* Call to enable property accessors. This method must be called
481+
* for any side effects of setting properties to occur. For elements,
482+
* generally `connectedCallback` is a normal spot to do so.
483+
* It is safe to call this method multiple times as it only turns
484+
* on property accessors once.
485+
*/
479486
_enableProperties() {
480-
if (!this.__dataPropertiesEnabled) {
481-
this.__dataPropertiesEnabled = true;
487+
if (!this.__dataEnabled) {
488+
this.__dataEnabled = true;
482489
if (this.__dataInstanceProps) {
483490
this._initializeInstanceProperties(this.__dataInstanceProps);
484491
this.__dataInstanceProps = null;
@@ -490,11 +497,9 @@
490497
/**
491498
* Calls the `_propertiesChanged` callback with the current set of
492499
* pending changes (and old values recorded when pending changes were
493-
* set), and resets the pending set of changes.
500+
* set), and resets the pending set of changes. Generally, this method
501+
* should not be called in user code.
494502
*
495-
* Note that this method must be called once to enable the property
496-
* accessors system. For elements, generally `connectedCallback`
497-
* is a normal spot to do so.
498503
*
499504
* @protected
500505
*/

lib/mixins/property-effects.html

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@
14611461
this.__dataPendingClients = null;
14621462
for (let i=0; i < clients.length; i++) {
14631463
let client = clients[i];
1464-
if (!client.__dataPropertiesEnabled) {
1464+
if (!client.__dataEnabled) {
14651465
client._enableProperties();
14661466
}
14671467
}
@@ -1496,13 +1496,21 @@
14961496
}
14971497

14981498
/**
1499-
* Overrides `PropertyAccessors` to call `_readyClients` callback
1500-
* if it was not called as a result of flushing properties.
1499+
* Overrides `PropertyAccessors` so that property accessor
1500+
* side effects are not enabled until after client dom is fully ready.
1501+
* Also calls `_flushClients` callback to ensure client dom is enabled
1502+
* that was not enabled as a result of flushing properties.
15011503
*
15021504
* @override
15031505
*/
15041506
ready() {
1507+
// It is important that `super.ready()` is not called here as it
1508+
// immediately turns on accessors. Instead, we wait until `readyClients`
1509+
// to enable accessors to provide a guarantee that clients are ready
1510+
// before processing any accessors side effects.
15051511
this._flushProperties();
1512+
// If no data was pending, `_flushProperties` will not `flushClients`
1513+
// so ensure this is done.
15061514
if (!this.__dataClientsInitialized) {
15071515
this._flushClients();
15081516
}
@@ -2215,6 +2223,8 @@
22152223
* @protected
22162224
*/
22172225
_stampTemplate(template) {
2226+
// Ensures that created dom is `_enqueueClient`'d to this element so
2227+
// that it can be flushed on next call to `_flushProperties`
22182228
hostStack.beginHosting(this);
22192229
let dom = super._stampTemplate(template);
22202230
hostStack.endHosting(this);

0 commit comments

Comments
 (0)