(
tNode: TElementNode | TElementContainerNode,
lView: LView,
index: number,
name: string,
locateOrCreateNativeNode: (
tView: TView,
lView: LView,
tNode: TNode,
name: string,
index: number,
) => RNode,
)
| 575 | |
| 576 | /** Shared code between instructions that indicate the start of an element. */ |
| 577 | export function elementLikeStartShared( |
| 578 | tNode: TElementNode | TElementContainerNode, |
| 579 | lView: LView, |
| 580 | index: number, |
| 581 | name: string, |
| 582 | locateOrCreateNativeNode: ( |
| 583 | tView: TView, |
| 584 | lView: LView, |
| 585 | tNode: TNode, |
| 586 | name: string, |
| 587 | index: number, |
| 588 | ) => RNode, |
| 589 | ) { |
| 590 | const adjustedIndex = HEADER_OFFSET + index; |
| 591 | const tView = lView[TVIEW]; |
| 592 | const native = locateOrCreateNativeNode(tView, lView, tNode, name, index); |
| 593 | lView[adjustedIndex] = native; |
| 594 | setCurrentTNode(tNode, true); |
| 595 | |
| 596 | // It's important that this runs before we've instantiated the directives. |
| 597 | const isElement = tNode.type === TNodeType.Element; |
| 598 | if (isElement) { |
| 599 | setupStaticAttributes(lView[RENDERER], native as RElement, tNode); |
| 600 | |
| 601 | // any immediate children of a component or template container must be pre-emptively |
| 602 | // monkey-patched with the component view data so that the element can be inspected |
| 603 | // later on using any element discovery utility methods (see `element_discovery.ts`) |
| 604 | if (getElementDepthCount() === 0 || isDirectiveHost(tNode)) { |
| 605 | attachPatchData(native, lView); |
| 606 | } |
| 607 | increaseElementDepthCount(); |
| 608 | } else { |
| 609 | attachPatchData(native, lView); |
| 610 | } |
| 611 | |
| 612 | if (wasLastNodeCreated() && (!isElement || !isDetachedByI18n(tNode))) { |
| 613 | // In the i18n case, the translation may have removed this element, so only add it if it is not |
| 614 | // detached. See `TNodeType.Placeholder` and `LFrame.inI18n` for more context. |
| 615 | appendChild(tView, lView, native, tNode); |
| 616 | } |
| 617 | |
| 618 | return tNode; |
| 619 | } |
| 620 | |
| 621 | /** Shared code between instructions that indicate the end of an element. */ |
| 622 | export function elementLikeEndShared(tNode: TNode): TNode { |
no test coverage detected
searching dependent graphs…