MCPcopy Index your code
hub / github.com/angular/angular / getOrCreateTNode

Function getOrCreateTNode

packages/core/src/render3/tnode_manipulation.ts:102–147  ·  view source on GitHub ↗
(
  tView: TView,
  index: number,
  type: TNodeType,
  name: string | null,
  attrs: TAttributes | null,
)

Source from the content-addressed store, hash-verified

100 | TIcuContainerNode
101 | TLetDeclarationNode;
102export 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
149export function createTNodeAtIndex(
150 tView: TView,

Callers 8

di_spec.tsFile · 0.90
domOnlyFirstCreatePassFunction · 0.90
ɵɵtextFunction · 0.90
ɵɵdeclareLetFunction · 0.90
ɵɵprojectionFunction · 0.90

Calls 8

assertGreaterThanOrEqualFunction · 0.90
assertPureTNodeTypeFunction · 0.90
isInI18nBlockFunction · 0.90
getCurrentParentTNodeFunction · 0.90
assertTNodeForTViewFunction · 0.90
assertEqualFunction · 0.90
setCurrentTNodeFunction · 0.90
createTNodeAtIndexFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…