refactor(ivy): separate first creation pass in the text instruction (#33894)
PR Close #33894
This commit is contained in:
parent
ffa3936b4c
commit
96499c898f
|
@ -6,10 +6,10 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
import {assertDataInRange, assertEqual} from '../../util/assert';
|
import {assertDataInRange, assertEqual} from '../../util/assert';
|
||||||
import {TNodeType} from '../interfaces/node';
|
import {TElementNode, TNodeType} from '../interfaces/node';
|
||||||
import {HEADER_OFFSET, RENDERER, TVIEW, T_HOST} from '../interfaces/view';
|
import {HEADER_OFFSET, RENDERER, TVIEW, T_HOST} from '../interfaces/view';
|
||||||
import {appendChild, createTextNode} from '../node_manipulation';
|
import {appendChild, createTextNode} from '../node_manipulation';
|
||||||
import {getBindingIndex, getLView, setIsNotParent} from '../state';
|
import {getBindingIndex, getLView, setPreviousOrParentTNode} from '../state';
|
||||||
|
|
||||||
import {getOrCreateTNode} from './shared';
|
import {getOrCreateTNode} from './shared';
|
||||||
|
|
||||||
|
@ -25,14 +25,21 @@ import {getOrCreateTNode} from './shared';
|
||||||
*/
|
*/
|
||||||
export function ɵɵtext(index: number, value: string = ''): void {
|
export function ɵɵtext(index: number, value: string = ''): void {
|
||||||
const lView = getLView();
|
const lView = getLView();
|
||||||
|
const tView = lView[TVIEW];
|
||||||
|
const adjustedIndex = index + HEADER_OFFSET;
|
||||||
|
|
||||||
ngDevMode && assertEqual(
|
ngDevMode && assertEqual(
|
||||||
getBindingIndex(), lView[TVIEW].bindingStartIndex,
|
getBindingIndex(), tView.bindingStartIndex,
|
||||||
'text nodes should be created before any bindings');
|
'text nodes should be created before any bindings');
|
||||||
ngDevMode && assertDataInRange(lView, index + HEADER_OFFSET);
|
ngDevMode && assertDataInRange(lView, adjustedIndex);
|
||||||
const textNative = lView[index + HEADER_OFFSET] = createTextNode(value, lView[RENDERER]);
|
|
||||||
const tNode = getOrCreateTNode(lView[TVIEW], lView[T_HOST], index, TNodeType.Element, null, null);
|
const tNode = tView.firstCreatePass ?
|
||||||
|
getOrCreateTNode(tView, lView[T_HOST], index, TNodeType.Element, null, null) :
|
||||||
|
tView.data[adjustedIndex] as TElementNode;
|
||||||
|
|
||||||
|
const textNative = lView[adjustedIndex] = createTextNode(value, lView[RENDERER]);
|
||||||
|
appendChild(textNative, tNode, lView);
|
||||||
|
|
||||||
// Text nodes are self closing.
|
// Text nodes are self closing.
|
||||||
setIsNotParent();
|
setPreviousOrParentTNode(tNode, false);
|
||||||
appendChild(textNative, tNode, lView);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,9 +464,6 @@
|
||||||
{
|
{
|
||||||
"name": "setInjectImplementation"
|
"name": "setInjectImplementation"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "setIsNotParent"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "setPreviousOrParentTNode"
|
"name": "setPreviousOrParentTNode"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue