@@ -238,6 +238,24 @@ function GenerateClassFromInfo(info, Base, behaviors) {
238
238
return observedAttributesGetter . call ( this ) . concat ( DISABLED_ATTR ) ;
239
239
}
240
240
241
+ // Prevent element from initializing properties when it's upgrade disabled.
242
+ /** @override */
243
+ _initializeProperties ( ) {
244
+ if ( ! this . hasAttribute ( DISABLED_ATTR ) ) {
245
+ super . _initializeProperties ( ) ;
246
+ } else {
247
+ this . __isUpgradeDisabled = true ;
248
+ }
249
+ }
250
+
251
+ // Prevent element from enabling properties when it's upgrade disabled.
252
+ /** @override */
253
+ _enableProperties ( ) {
254
+ if ( ! this . __isUpgradeDisabled ) {
255
+ super . _enableProperties ( ) ;
256
+ }
257
+ }
258
+
241
259
/**
242
260
* @override
243
261
* @param {string } name Attribute name.
@@ -248,48 +266,33 @@ function GenerateClassFromInfo(info, Base, behaviors) {
248
266
*/
249
267
attributeChangedCallback ( name , old , value , namespace ) {
250
268
if ( name == DISABLED_ATTR ) {
251
- if ( ! this . __dataEnabled && value == null && this . isConnected ) {
252
- super . connectedCallback ( ) ;
269
+ // When disable-upgrade is removed, intialize properties and
270
+ // provoke connectedCallback if the element is already connected.
271
+ if ( ! this . __dataEnabled && value == null ) {
272
+ super . _initializeProperties ( ) ;
273
+ this . __isUpgradeDisabled = false ;
274
+ if ( this . isConnected ) {
275
+ super . connectedCallback ( ) ;
276
+ }
253
277
}
254
278
} else {
255
279
super . attributeChangedCallback (
256
280
name , old , value , /** @type {null|string } */ ( namespace ) ) ;
257
281
}
258
282
}
259
283
260
-
261
- // prevent user code in connected from running
284
+ // Prevent element from connecting when it's upgrade disabled.
262
285
/** @override */
263
286
connectedCallback ( ) {
264
- if ( this . __dataEnabled || ! this . hasAttribute ( DISABLED_ATTR ) ) {
287
+ if ( ! this . __isUpgradeDisabled ) {
265
288
super . connectedCallback ( ) ;
266
289
}
267
290
}
268
291
269
- _initializeProperties ( ) {
270
- if ( ! this . hasAttribute ( DISABLED_ATTR ) ) {
271
- super . _initializeProperties ( ) ;
272
- } else {
273
- this . __wasDisabled = true ;
274
- }
275
- }
276
-
277
- // prevent element from turning on properties
278
- /** @override */
279
- _enableProperties ( ) {
280
- if ( this . __wasDisabled ) {
281
- this . __wasDisabled = false ;
282
- super . _initializeProperties ( ) ;
283
- }
284
- if ( ! this . hasAttribute ( DISABLED_ATTR ) ) {
285
- super . _enableProperties ( ) ;
286
- }
287
- }
288
-
289
- // only go if "enabled"
292
+ // Prevent element from disconnecting when it's upgrade disabled.
290
293
/** @override */
291
294
disconnectedCallback ( ) {
292
- if ( this . __dataEnabled ) {
295
+ if ( ! this . __isUpgradeDisabled ) {
293
296
super . disconnectedCallback ( ) ;
294
297
}
295
298
}
0 commit comments