@@ -1095,19 +1095,21 @@ export class AmpList extends AMP.BaseElement {
1095
1095
1096
1096
// binding=refresh: Only do render-blocking update after initial render.
1097
1097
if ( binding && binding . startsWith ( 'refresh' ) ) {
1098
- // Don't bother using bindForDocOrNull() since the Bind service must be available after first mutate.
1099
- const afterFirstMutate =
1100
- this . bind_ && this . bind_ . signals ( ) . get ( 'FIRST_MUTATE' ) ;
1101
- if ( afterFirstMutate ) {
1098
+ // Bind service must be available after first mutation, so don't
1099
+ // wait on the async service getter.
1100
+ if ( this . bind_ && this . bind_ . signals ( ) . get ( 'FIRST_MUTATE' ) ) {
1102
1101
return updateWith ( this . bind_ ) ;
1103
1102
} else {
1104
- // This must be initial render, so do a non-blocking scan for bindings only.
1105
- // [diffable] is a special case that is handled later in render_(), see comment there.
1106
- if ( ! this . element . hasAttribute ( 'diffable' ) ) {
1107
- this . scanForBindings_ ( elements , [ ] ) ;
1108
- }
1109
-
1110
- // Don't block render and return synchronously.
1103
+ // On initial render, do a non-blocking scan and don't update.
1104
+ Services . bindForDocOrNull ( this . element ) . then ( ( bind ) => {
1105
+ if ( bind ) {
1106
+ const evaluate = binding == 'refresh-evaluate' ;
1107
+ bind . rescan ( elements , [ ] , {
1108
+ 'fast' : true ,
1109
+ 'update' : evaluate ? 'evaluate' : false ,
1110
+ } ) ;
1111
+ }
1112
+ } ) ;
1111
1113
return Promise . resolve ( elements ) ;
1112
1114
}
1113
1115
}
@@ -1122,32 +1124,6 @@ export class AmpList extends AMP.BaseElement {
1122
1124
} ) ;
1123
1125
}
1124
1126
1125
- /**
1126
- * Scans for bindings in `addedElements` and removes bindings in `removedElements`.
1127
- * Unlike updateBindings(), does NOT apply bindings or update DOM.
1128
- * Should only be used for binding="refresh" or binding="refresh-evaluate".
1129
- * @param {!Array<!Element> } addedElements
1130
- * @param {!Array<!Element> } removedElements
1131
- * @private
1132
- */
1133
- scanForBindings_ ( addedElements , removedElements ) {
1134
- const binding = this . element . getAttribute ( 'binding' ) ;
1135
- if ( ! binding || ! binding . startsWith ( 'refresh' ) ) {
1136
- return ;
1137
- }
1138
- Services . bindForDocOrNull ( this . element ) . then ( ( bind ) => {
1139
- if ( bind ) {
1140
- // For binding="refresh-evaluate", we scan for bindings, evaluate+cache expressions, but skip DOM update.
1141
- // For binding="refresh", we only scan for bindings.
1142
- const update = binding == 'refresh-evaluate' ? 'evaluate' : false ;
1143
- bind . rescan ( addedElements , removedElements , {
1144
- 'fast' : true ,
1145
- 'update' : update ,
1146
- } ) ;
1147
- }
1148
- } ) ;
1149
- }
1150
-
1151
1127
/**
1152
1128
* @param {!Array<!Element> } elements
1153
1129
* @param {boolean= } opt_append
@@ -1164,14 +1140,6 @@ export class AmpList extends AMP.BaseElement {
1164
1140
// TODO:(wg-performance)(#28781) Ensure owners_.scheduleUnlayout() is
1165
1141
// called for diff elements that are removed
1166
1142
this . diff_ ( container , elements ) ;
1167
-
1168
- // For diffable amp-list, we have to wait until DOM diffing is done here to scan for new bindings
1169
- // (vs. asynchronously in updateBindings()), and scan the entire container (vs. just `elements`).
1170
- //
1171
- // This is because instead of replacing the entire DOM subtree, the diffing process removes
1172
- // select children from `elements` and inserts them into the container. This results in a race
1173
- // between diff_() and Bind.rescan(), which we avoid by delaying the latter until now.
1174
- this . scanForBindings_ ( [ container ] , [ container ] ) ;
1175
1143
} else {
1176
1144
if ( ! opt_append ) {
1177
1145
this . owners_ . /*OK*/ scheduleUnlayout ( this . element , container ) ;
0 commit comments