MCPcopy Create free account
hub / github.com/angular/angular / stylingFirstUpdatePass

Function stylingFirstUpdatePass

packages/core/src/render3/instructions/styling.ts:360–387  ·  view source on GitHub ↗

* Collects the necessary information to insert the binding into a linked list of style bindings * using `insertTStylingBinding`. * * @param tView `TView` where the binding linked list will be stored. * @param tStylingKey Property/key of the binding. * @param bindingIndex Index of binding associ

(
  tView: TView,
  tStylingKey: TStylingKey,
  bindingIndex: number,
  isClassBased: boolean,
)

Source from the content-addressed store, hash-verified

358 * @param isClassBased `true` if `class` change (`false` if `style`)
359 */
360function stylingFirstUpdatePass(
361 tView: TView,
362 tStylingKey: TStylingKey,
363 bindingIndex: number,
364 isClassBased: boolean,
365): void {
366 ngDevMode && assertFirstUpdatePass(tView);
367 const tData = tView.data;
368 if (tData[bindingIndex + 1] === null) {
369 // The above check is necessary because we don't clear first update pass until first successful
370 // (no exception) template execution. This prevents the styling instruction from double adding
371 // itself to the list.
372 // `getSelectedIndex()` should be here (rather than in instruction) so that it is guarded by the
373 // if so as not to read unnecessarily.
374 const tNode = tData[getSelectedIndex()] as TNode;
375 ngDevMode && assertDefined(tNode, 'TNode expected');
376 const isHostBindings = isInHostBindings(tView, bindingIndex);
377 if (hasStylingInputShadow(tNode, isClassBased) && tStylingKey === null && !isHostBindings) {
378 // `tStylingKey === null` implies that we are either `[style]` or `[class]` binding.
379 // If there is a directive which uses `@Input('style')` or `@Input('class')` than
380 // we need to neutralize this binding since that directive is shadowing it.
381 // We turn this into a noop by setting the key to `false`
382 tStylingKey = false;
383 }
384 tStylingKey = wrapInStaticStylingKey(tData, tNode, tStylingKey, isClassBased);
385 insertTStylingBinding(tData, tNode, tStylingKey, bindingIndex, isHostBindings, isClassBased);
386 }
387}
388
389/**
390 * Adds static styling information to the binding if applicable.

Callers 2

checkStylingPropertyFunction · 0.85
checkStylingMapFunction · 0.85

Calls 7

assertFirstUpdatePassFunction · 0.90
getSelectedIndexFunction · 0.90
assertDefinedFunction · 0.90
insertTStylingBindingFunction · 0.90
isInHostBindingsFunction · 0.85
hasStylingInputShadowFunction · 0.85
wrapInStaticStylingKeyFunction · 0.85

Tested by

no test coverage detected