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

Function collectResidual

packages/core/src/render3/instructions/styling.ts:590–610  ·  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

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