(lContainer: LContainer, index: number)
| 46 | * @param index The index at which to insert the view. |
| 47 | */ |
| 48 | export function createForeignView(lContainer: LContainer, index: number): ForeignViewRef<unknown> { |
| 49 | const declLView = lContainer[PARENT] as LView; |
| 50 | const declTNode = lContainer[T_HOST]; |
| 51 | const renderer = declLView[RENDERER]; |
| 52 | |
| 53 | // 1. Create TView with 3 slots (head, tail, fragment) |
| 54 | const tView = createTView( |
| 55 | TViewType.Foreign, |
| 56 | declTNode, // link to container host |
| 57 | null, // templateFn (safe! Checked by renderView) |
| 58 | 3, // decls |
| 59 | 0, // vars |
| 60 | null, |
| 61 | null, |
| 62 | null, |
| 63 | null, |
| 64 | null, |
| 65 | null, |
| 66 | ); |
| 67 | |
| 68 | // 2. Create TNodes for head and tail to make them addressable |
| 69 | const headTNode = (tView.data[HEADER_OFFSET] = createTNode( |
| 70 | tView, |
| 71 | null, |
| 72 | TNodeType.Element, |
| 73 | HEADER_OFFSET, |
| 74 | '', |
| 75 | null, |
| 76 | )); |
| 77 | const tailTNode = (tView.data[HEADER_OFFSET + 1] = createTNode( |
| 78 | tView, |
| 79 | null, |
| 80 | TNodeType.Element, |
| 81 | HEADER_OFFSET + 1, |
| 82 | '', |
| 83 | null, |
| 84 | )); |
| 85 | |
| 86 | // 3. Link them in the view |
| 87 | tView.firstChild = headTNode; |
| 88 | headTNode.next = tailTNode; |
| 89 | tailTNode.prev = headTNode; |
| 90 | |
| 91 | // 4. Create LView |
| 92 | const lView = createLView( |
| 93 | declLView, |
| 94 | tView, |
| 95 | null, |
| 96 | 0 as LViewFlags, // Do not set CheckAlways for foreign views |
| 97 | null, |
| 98 | null, |
| 99 | null, |
| 100 | renderer, // pass it through |
| 101 | null, |
| 102 | null, |
| 103 | null, |
| 104 | ); |
| 105 |
no test coverage detected