@@ -579,24 +579,29 @@ export abstract class UpdatingElement extends HTMLElement {
579
579
*/
580
580
requestUpdate ( name ?: PropertyKey , oldValue ?: unknown ) {
581
581
let shouldRequestUpdate = true ;
582
- // if we have a property key, perform property update steps.
583
- if ( name !== undefined && ! this . _changedProperties . has ( name ) ) {
582
+ // If we have a property key, perform property update steps.
583
+ if ( name !== undefined ) {
584
584
const ctor = this . constructor as typeof UpdatingElement ;
585
585
const options =
586
586
ctor . _classProperties ! . get ( name ) || defaultPropertyDeclaration ;
587
587
if ( ctor . _valueHasChanged (
588
588
this [ name as keyof this] , oldValue , options . hasChanged ) ) {
589
- // track old value when changing.
590
- this . _changedProperties . set ( name , oldValue ) ;
591
- // add to reflecting properties set
589
+ // Track old value when changing.
590
+ if ( ! this . _changedProperties . has ( name ) ) {
591
+ this . _changedProperties . set ( name , oldValue ) ;
592
+ }
593
+ // Add to reflecting properties set.
594
+ // Note, it's important that every change has a chance to add the
595
+ // property to `_reflectingProperties`. This ensures setting
596
+ // attribute + property reflects correctly.
592
597
if ( options . reflect === true &&
593
598
! ( this . _updateState & STATE_IS_REFLECTING_TO_PROPERTY ) ) {
594
599
if ( this . _reflectingProperties === undefined ) {
595
600
this . _reflectingProperties = new Map ( ) ;
596
601
}
597
602
this . _reflectingProperties . set ( name , options ) ;
598
603
}
599
- // abort the request if the property should not be considered changed.
604
+ // Abort the request if the property should not be considered changed.
600
605
} else {
601
606
shouldRequestUpdate = false ;
602
607
}
0 commit comments