( lView: LView, index: number, textOrName: string, nodeType: typeof Node.COMMENT_NODE | typeof Node.TEXT_NODE | typeof Node.ELEMENT_NODE, )
| 146 | }; |
| 147 | |
| 148 | function locateOrCreateNodeImpl( |
| 149 | lView: LView, |
| 150 | index: number, |
| 151 | textOrName: string, |
| 152 | nodeType: typeof Node.COMMENT_NODE | typeof Node.TEXT_NODE | typeof Node.ELEMENT_NODE, |
| 153 | ) { |
| 154 | const hydrationInfo = lView[HYDRATION]; |
| 155 | const noOffsetIndex = index - HEADER_OFFSET; |
| 156 | const isNodeCreationMode = |
| 157 | !isI18nHydrationSupportEnabled() || |
| 158 | !hydrationInfo || |
| 159 | isInSkipHydrationBlock() || |
| 160 | isDisconnectedNode(hydrationInfo, noOffsetIndex); |
| 161 | |
| 162 | lastNodeWasCreated(isNodeCreationMode); |
| 163 | if (isNodeCreationMode) { |
| 164 | return createNodeWithoutHydration(lView, textOrName, nodeType); |
| 165 | } |
| 166 | |
| 167 | const native = locateI18nRNodeByIndex(hydrationInfo!, noOffsetIndex) as RNode; |
| 168 | |
| 169 | // TODO: Improve error handling |
| 170 | // |
| 171 | // Other hydration paths use validateMatchingNode() in order to provide |
| 172 | // detailed information in development mode about the expected DOM. |
| 173 | // However, not every node in an i18n block has a TNode. Instead, we |
| 174 | // need to be able to use the AST to generate a similar message. |
| 175 | ngDevMode && assertDefined(native, 'expected native element'); |
| 176 | ngDevMode && assertEqual((native as Node).nodeType, nodeType, 'expected matching nodeType'); |
| 177 | ngDevMode && |
| 178 | nodeType === Node.ELEMENT_NODE && |
| 179 | assertEqual( |
| 180 | (native as HTMLElement).tagName.toLowerCase(), |
| 181 | textOrName.toLowerCase(), |
| 182 | 'expecting matching tagName', |
| 183 | ); |
| 184 | ngDevMode && markRNodeAsClaimedByHydration(native); |
| 185 | |
| 186 | return native; |
| 187 | } |
| 188 | |
| 189 | export function enableLocateOrCreateI18nNodeImpl() { |
| 190 | _locateOrCreateNode = locateOrCreateNodeImpl; |
nothing calls this directly
no test coverage detected
searching dependent graphs…