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

Function collectResidual

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

* Collect all static values after the current `TNode.directiveStylingLast` index. * * Collect the remaining styling information which has not yet been collected by an existing * styling instruction. * * @param tData `TData` where the `DirectiveDefs` are stored. * @param tNode `TNode` which con

(
  tData: TData,
  tNode: TNode,
  isClassBased: boolean,
)

Source from the content-addressed store, hash-verified

585 * @param isClassBased `true` if `class` (`false` if `style`)
586 */
587function collectResidual(
588 tData: TData,
589 tNode: TNode,
590 isClassBased: boolean,
591): KeyValueArray<any> | null {
592 let residual: KeyValueArray<any> | null | undefined = undefined;
593 const directiveEnd = tNode.directiveEnd;
594 ngDevMode &&
595 assertNotEqual(
596 tNode.directiveStylingLast,
597 -1,
598 'By the time this function gets called at least one hostBindings-node styling instruction must have executed.',
599 );
600 // We add `1 + tNode.directiveStart` because we need to skip the current directive (as we are
601 // collecting things after the last `hostBindings` directive which had a styling instruction.)
602 for (let i = 1 + tNode.directiveStylingLast; i < directiveEnd; i++) {
603 const attrs = (tData[i] as DirectiveDef<any>).hostAttrs;
604 residual = collectStylingFromTAttrs(residual, attrs, isClassBased) as KeyValueArray<any> | null;
605 }
606 return collectStylingFromTAttrs(residual, tNode.attrs, isClassBased) as KeyValueArray<any> | null;
607}
608
609/**
610 * Collect the static styling information with lower priority than `hostDirectiveDef`.

Callers 1

wrapInStaticStylingKeyFunction · 0.85

Calls 2

assertNotEqualFunction · 0.90
collectStylingFromTAttrsFunction · 0.85

Tested by

no test coverage detected