2019-04-01 15:36:43 -07:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
2019-08-27 15:16:50 +02:00
|
|
|
import {assertDataInRange, assertEqual} from '../../util/assert';
|
2019-04-01 15:36:43 -07:00
|
|
|
import {TNodeType} from '../interfaces/node';
|
2019-08-27 15:16:50 +02:00
|
|
|
import {BINDING_INDEX, HEADER_OFFSET, RENDERER, TVIEW, T_HOST} from '../interfaces/view';
|
2019-04-01 15:36:43 -07:00
|
|
|
import {appendChild, createTextNode} from '../node_manipulation';
|
2019-08-27 16:44:11 +02:00
|
|
|
import {getLView, setIsNotParent} from '../state';
|
|
|
|
import {getOrCreateTNode} from './shared';
|
2019-05-31 14:41:07 -07:00
|
|
|
|
|
|
|
|
2019-04-01 15:36:43 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create static text node
|
|
|
|
*
|
|
|
|
* @param index Index of the node in the data array
|
2019-08-27 15:16:50 +02:00
|
|
|
* @param value Static string value to write.
|
2019-04-04 11:41:52 -07:00
|
|
|
*
|
2019-04-10 13:45:26 -07:00
|
|
|
* @codeGenApi
|
2019-04-01 15:36:43 -07:00
|
|
|
*/
|
2019-08-27 15:16:50 +02:00
|
|
|
export function ɵɵtext(index: number, value: string = ''): void {
|
2019-04-01 15:36:43 -07:00
|
|
|
const lView = getLView();
|
|
|
|
ngDevMode && assertEqual(
|
|
|
|
lView[BINDING_INDEX], lView[TVIEW].bindingStartIndex,
|
|
|
|
'text nodes should be created before any bindings');
|
2019-05-15 20:59:55 -07:00
|
|
|
ngDevMode && assertDataInRange(lView, index + HEADER_OFFSET);
|
|
|
|
const textNative = lView[index + HEADER_OFFSET] = createTextNode(value, lView[RENDERER]);
|
2019-05-15 22:51:40 -07:00
|
|
|
const tNode = getOrCreateTNode(lView[TVIEW], lView[T_HOST], index, TNodeType.Element, null, null);
|
2019-04-01 15:36:43 -07:00
|
|
|
|
|
|
|
// Text nodes are self closing.
|
2019-05-14 21:47:11 -07:00
|
|
|
setIsNotParent();
|
2019-04-01 15:36:43 -07:00
|
|
|
appendChild(textNative, tNode, lView);
|
|
|
|
}
|