@@ -1063,6 +1063,56 @@ suite('LitElement', () => {
1063
1063
assert . equal ( el . wasFirstUpdated , 1 ) ;
1064
1064
} ) ;
1065
1065
1066
+ test (
1067
+ '`firstUpdated` called when element first updates even if first `shouldUpdate` returned false' , async ( ) => {
1068
+ class E extends LitElement {
1069
+
1070
+ @property ( )
1071
+ foo = 1 ;
1072
+
1073
+ triedToUpdatedCount = 0 ;
1074
+ wasUpdatedCount = 0 ;
1075
+ wasFirstUpdated = 0 ;
1076
+ changedProperties : PropertyValues | undefined ;
1077
+
1078
+ shouldUpdate ( ) {
1079
+ this . triedToUpdatedCount ++ ;
1080
+ return this . triedToUpdatedCount > 1 ;
1081
+ }
1082
+
1083
+ update ( changedProperties : PropertyValues ) {
1084
+ this . wasUpdatedCount ++ ;
1085
+ super . update ( changedProperties ) ;
1086
+ }
1087
+
1088
+ render ( ) { return html `` ; }
1089
+
1090
+ firstUpdated ( changedProperties : PropertyValues ) {
1091
+ this . changedProperties = changedProperties ;
1092
+ this . wasFirstUpdated ++ ;
1093
+ }
1094
+ }
1095
+
1096
+ customElements . define ( generateElementName ( ) , E ) ;
1097
+ const el = new E ( ) ;
1098
+ container . appendChild ( el ) ;
1099
+ await el . updateComplete ;
1100
+ const testMap = new Map ( ) ;
1101
+ testMap . set ( 'foo' , undefined ) ;
1102
+ assert . equal ( el . triedToUpdatedCount , 1 ) ;
1103
+ assert . equal ( el . wasUpdatedCount , 0 ) ;
1104
+ assert . equal ( el . wasFirstUpdated , 0 ) ;
1105
+ await el . requestUpdate ( ) ;
1106
+ assert . deepEqual ( el . changedProperties , testMap ) ;
1107
+ assert . equal ( el . triedToUpdatedCount , 2 ) ;
1108
+ assert . equal ( el . wasUpdatedCount , 1 ) ;
1109
+ assert . equal ( el . wasFirstUpdated , 1 ) ;
1110
+ await el . requestUpdate ( ) ;
1111
+ assert . equal ( el . triedToUpdatedCount , 3 ) ;
1112
+ assert . equal ( el . wasUpdatedCount , 2 ) ;
1113
+ assert . equal ( el . wasFirstUpdated , 1 ) ;
1114
+ } ) ;
1115
+
1066
1116
test (
1067
1117
'render lifecycle order' , async ( ) => {
1068
1118
class E extends LitElement {
0 commit comments