( tView: TView, index: number, type: TNodeType, name: string | null, attrs: TAttributes | null, )
| 100 | | TIcuContainerNode |
| 101 | | TLetDeclarationNode; |
| 102 | export function getOrCreateTNode( |
| 103 | tView: TView, |
| 104 | index: number, |
| 105 | type: TNodeType, |
| 106 | name: string | null, |
| 107 | attrs: TAttributes | null, |
| 108 | ): |
| 109 | | TElementNode |
| 110 | | TContainerNode |
| 111 | | TElementContainerNode |
| 112 | | TProjectionNode |
| 113 | | TIcuContainerNode |
| 114 | | TLetDeclarationNode { |
| 115 | ngDevMode && |
| 116 | index !== 0 && // 0 are bogus nodes and they are OK. See `createContainerRef` in |
| 117 | // `view_engine_compatibility` for additional context. |
| 118 | assertGreaterThanOrEqual(index, HEADER_OFFSET, "TNodes can't be in the LView header."); |
| 119 | // Keep this function short, so that the VM will inline it. |
| 120 | ngDevMode && assertPureTNodeType(type); |
| 121 | let tNode = tView.data[index] as TNode; |
| 122 | if (tNode === null) { |
| 123 | tNode = createTNodeAtIndex(tView, index, type, name, attrs); |
| 124 | if (isInI18nBlock()) { |
| 125 | // If we are in i18n block then all elements should be pre declared through `Placeholder` |
| 126 | // See `TNodeType.Placeholder` and `LFrame.inI18n` for more context. |
| 127 | // If the `TNode` was not pre-declared than it means it was not mentioned which means it was |
| 128 | // removed, so we mark it as detached. |
| 129 | tNode.flags |= TNodeFlags.isDetached; |
| 130 | } |
| 131 | } else if (tNode.type & TNodeType.Placeholder) { |
| 132 | tNode.type = type; |
| 133 | tNode.value = name; |
| 134 | tNode.attrs = attrs; |
| 135 | const parent = getCurrentParentTNode(); |
| 136 | tNode.injectorIndex = parent === null ? -1 : parent.injectorIndex; |
| 137 | ngDevMode && assertTNodeForTView(tNode, tView); |
| 138 | ngDevMode && assertEqual(index, tNode.index, 'Expecting same index'); |
| 139 | } |
| 140 | setCurrentTNode(tNode, true); |
| 141 | return tNode as |
| 142 | | TElementNode |
| 143 | | TContainerNode |
| 144 | | TElementContainerNode |
| 145 | | TProjectionNode |
| 146 | | TIcuContainerNode; |
| 147 | } |
| 148 | |
| 149 | export function createTNodeAtIndex( |
| 150 | tView: TView, |
no test coverage detected
searching dependent graphs…