File tree Expand file tree Collapse file tree 7 files changed +29
-24
lines changed Expand file tree Collapse file tree 7 files changed +29
-24
lines changed Original file line number Diff line number Diff line change 103
103
for ( let n = this . root . firstChild ; n ; n = n . nextSibling ) {
104
104
this . __children [ this . __children . length ] = n ;
105
105
}
106
- this . _flushProperties ( ) ;
106
+ this . _enableProperties ( ) ;
107
107
}
108
108
this . __insertChildren ( ) ;
109
109
this . dispatchEvent ( new CustomEvent ( 'dom-change' , {
Original file line number Diff line number Diff line change 631
631
if ( window . ShadyCSS && this . _template ) {
632
632
window . ShadyCSS . styleElement ( this ) ;
633
633
}
634
- if ( ! this . __dataInitialized ) {
635
- this . _flushProperties ( ) ;
636
- }
634
+ this . _enableProperties ( ) ;
637
635
}
638
636
639
637
/**
Original file line number Diff line number Diff line change 475
475
}
476
476
}
477
477
478
+ // TODO(kschaaf): document.
479
+ _enableProperties ( ) {
480
+ if ( ! this . __dataPropertiesEnabled ) {
481
+ this . __dataPropertiesEnabled = true ;
482
+ if ( this . __dataInstanceProps ) {
483
+ this . _initializeInstanceProperties ( this . __dataInstanceProps ) ;
484
+ this . __dataInstanceProps = null ;
485
+ }
486
+ this . ready ( )
487
+ }
488
+ }
489
+
478
490
/**
479
491
* Calls the `_propertiesChanged` callback with the current set of
480
492
* pending changes (and old values recorded when pending changes were
487
499
* @protected
488
500
*/
489
501
_flushProperties ( ) {
490
- if ( ! this . __dataInitialized ) {
491
- this . ready ( )
492
- } else if ( this . __dataPending ) {
502
+ if ( this . __dataPending ) {
493
503
let changedProps = this . __dataPending ;
494
504
this . __dataPending = null ;
495
505
this . __dataCounter ++ ;
513
523
* @public
514
524
*/
515
525
ready ( ) {
516
- // Update instance properties that shadowed proto accessors; these take
517
- // priority over any defaults set in constructor or attributeChangedCallback
518
- if ( this . __dataInstanceProps ) {
519
- this . _initializeInstanceProperties ( this . __dataInstanceProps ) ;
520
- this . __dataInstanceProps = null ;
521
- }
522
526
this . __dataInitialized = true ;
523
527
// Run normal flush
524
528
this . _flushProperties ( ) ;
Original file line number Diff line number Diff line change 230
230
// And the host has already initialized clients; this prevents
231
231
// an issue with a host observing data changes before clients are ready.
232
232
let host ;
233
- if ( notified && ( host = inst . __dataHost ) && host . _flushProperties
234
- && host . __dataClientsInitialized ) {
235
- host . _flushProperties ( ) ;
233
+ if ( notified && ( host = inst . __dataHost ) && host . _invalidateProperties ) {
234
+ host . _invalidateProperties ( ) ;
236
235
}
237
236
}
238
237
1430
1429
*/
1431
1430
_flushClients ( ) {
1432
1431
if ( ! this . __dataClientsInitialized ) {
1432
+ this . __dataClientsInitialized = true ;
1433
1433
this . _readyClients ( ) ;
1434
1434
}
1435
1435
// Flush all clients
1438
1438
this . __dataPendingClients = null ;
1439
1439
for ( let i = 0 ; i < clients . length ; i ++ ) {
1440
1440
let client = clients [ i ] ;
1441
- if ( ! client . __dataInitialized || client . __dataPending ) {
1441
+ // boot up client if necessary, otherwise flush properties
1442
+ if ( ! client . __dataPropertiesEnabled ) {
1443
+ client . _enableProperties ( ) ;
1444
+ } else if ( client . __dataPending ) {
1442
1445
client . _flushProperties ( ) ;
1443
1446
}
1444
1447
}
1479
1482
* @override
1480
1483
*/
1481
1484
ready ( ) {
1482
- super . ready ( ) ;
1485
+ this . _flushProperties ( ) ;
1483
1486
if ( ! this . __dataClientsInitialized ) {
1484
- this . _readyClients ( ) ;
1487
+ this . _flushClients ( ) ;
1485
1488
}
1486
1489
// Before ready, client notifications do not trigger _flushProperties.
1487
1490
// Therefore a flush is necessary here if data has been set.
1498
1501
* @protected
1499
1502
*/
1500
1503
_readyClients ( ) {
1501
- this . __dataClientsInitialized = true ;
1504
+ this . __dataInitialized = true ;
1502
1505
}
1503
1506
1504
1507
/**
Original file line number Diff line number Diff line change 63
63
// or when there isn't instance props.
64
64
let options = this . __templatizeOptions ;
65
65
if ( ( props && options . instanceProps ) || ! options . instanceProps ) {
66
- this . _flushProperties ( ) ;
66
+ this . _enableProperties ( ) ;
67
67
}
68
68
}
69
69
/**
251
251
template . __dataTemp = { } ;
252
252
template . __dataPending = null ;
253
253
template . __dataOld = null ;
254
- template . _flushProperties ( ) ;
254
+ template . _enableProperties ( ) ;
255
255
}
256
256
}
257
257
Original file line number Diff line number Diff line change 29
29
this . _propertiesChanged = sinon . spy ( ) ;
30
30
}
31
31
connectedCallback ( ) {
32
- this . _flushProperties ( ) ;
32
+ this . _enableProperties ( ) ;
33
33
}
34
34
}
35
35
XFoo . createPropertiesForAttributes ( ) ;
Original file line number Diff line number Diff line change 1514
1514
BaseClass = class extends Polymer . PropertyEffects ( HTMLElement ) {
1515
1515
connectedCallback ( ) {
1516
1516
this . pcSpy = sinon . spy ( ) ;
1517
- this . _flushProperties ( ) ;
1517
+ this . _enableProperties ( ) ;
1518
1518
}
1519
1519
_propertiesChanged ( props , changedProps , oldProps ) {
1520
1520
this . pcSpy ( props , changedProps , oldProps ) ;
You can’t perform that action at this time.
0 commit comments