refactor(core): add a checkIndex to the compiler view nodes
Each node now has two index: nodeIndex and checkIndex. nodeIndex is the index in both the view definition and the view data. checkIndex is the index in in the update function (update directives and update renderer). While nodeIndex and checkIndex have the same value for now, having both of them will allow changing the structure of view definition after compilation (ie for runtime translations).
This commit is contained in:

committed by
Alex Rickabaugh

parent
caa51950e8
commit
0833b59aab
@ -9,7 +9,8 @@
|
||||
import {BindingDef, BindingFlags, NodeDef, NodeFlags, TextData, ViewData, asTextData} from './types';
|
||||
import {checkAndUpdateBinding, getParentRenderElement} from './util';
|
||||
|
||||
export function textDef(ngContentIndex: number, staticText: string[]): NodeDef {
|
||||
export function textDef(
|
||||
checkIndex: number, ngContentIndex: number | null, staticText: string[]): NodeDef {
|
||||
const bindings: BindingDef[] = new Array(staticText.length - 1);
|
||||
for (let i = 1; i < staticText.length; i++) {
|
||||
bindings[i - 1] = {
|
||||
@ -24,12 +25,13 @@ export function textDef(ngContentIndex: number, staticText: string[]): NodeDef {
|
||||
|
||||
return {
|
||||
// will bet set by the view definition
|
||||
index: -1,
|
||||
nodeIndex: -1,
|
||||
parent: null,
|
||||
renderParent: null,
|
||||
bindingIndex: -1,
|
||||
outputIndex: -1,
|
||||
// regular values
|
||||
checkIndex,
|
||||
flags: NodeFlags.TypeText,
|
||||
childFlags: 0,
|
||||
directChildFlags: 0,
|
||||
@ -88,7 +90,7 @@ export function checkAndUpdateTextInline(
|
||||
if (bindLen > 7) value += _addInterpolationPart(v7, bindings[7]);
|
||||
if (bindLen > 8) value += _addInterpolationPart(v8, bindings[8]);
|
||||
if (bindLen > 9) value += _addInterpolationPart(v9, bindings[9]);
|
||||
const renderNode = asTextData(view, def.index).renderText;
|
||||
const renderNode = asTextData(view, def.nodeIndex).renderText;
|
||||
view.renderer.setValue(renderNode, value);
|
||||
}
|
||||
return changed;
|
||||
@ -110,7 +112,7 @@ export function checkAndUpdateTextDynamic(view: ViewData, def: NodeDef, values:
|
||||
value = value + _addInterpolationPart(values[i], bindings[i]);
|
||||
}
|
||||
value = def.text !.prefix + value;
|
||||
const renderNode = asTextData(view, def.index).renderText;
|
||||
const renderNode = asTextData(view, def.nodeIndex).renderText;
|
||||
view.renderer.setValue(renderNode, value);
|
||||
}
|
||||
return changed;
|
||||
|
Reference in New Issue
Block a user