diff --git a/packages/core/src/render3/i18n/i18n_parse.ts b/packages/core/src/render3/i18n/i18n_parse.ts index 79667119a5..44bf466091 100644 --- a/packages/core/src/render3/i18n/i18n_parse.ts +++ b/packages/core/src/render3/i18n/i18n_parse.ts @@ -17,7 +17,7 @@ import {loadIcuContainerVisitor} from '../instructions/i18n_icu_container_visito import {allocExpando, createTNodeAtIndex, elementAttributeInternal, setInputsForProperty, setNgReflectProperties} from '../instructions/shared'; import {getDocument} from '../interfaces/document'; import {COMMENT_MARKER, ELEMENT_MARKER, ensureIcuContainerVisitorLoaded, I18nCreateOpCode, I18nCreateOpCodes, I18nMutateOpCode, i18nMutateOpCode, I18nMutateOpCodes, I18nUpdateOpCode, I18nUpdateOpCodes, IcuExpression, IcuType, TI18n, TIcu} from '../interfaces/i18n'; -import {TNode, TNodeType} from '../interfaces/node'; +import {TIcuContainerNode, TNode, TNodeType} from '../interfaces/node'; import {RComment, RElement} from '../interfaces/renderer'; import {SanitizerFn} from '../interfaces/sanitization'; import {HEADER_OFFSET, LView, TView} from '../interfaces/view'; diff --git a/packages/core/src/render3/i18n/i18n_util.ts b/packages/core/src/render3/i18n/i18n_util.ts index 8993c6093d..ce300e9539 100644 --- a/packages/core/src/render3/i18n/i18n_util.ts +++ b/packages/core/src/render3/i18n/i18n_util.ts @@ -40,9 +40,8 @@ export function getTIcu(tView: TView, index: number): TIcu|null { // either TIcu or TIcuContainerNode. This is not ideal, but we still think it is OK because it // will be just two cases which fits into the browser inline cache (inline cache can take up to // 4) - const tIcu: TIcu = value.hasOwnProperty('currentCaseLViewIndex') ? - value : - (value as TIcuContainerNode).value as any; + const tIcu = value.hasOwnProperty('currentCaseLViewIndex') ? value as TIcu : + (value as TIcuContainerNode).value; ngDevMode && assertTIcu(tIcu); return tIcu; } @@ -71,7 +70,7 @@ export function setTIcu(tView: TView, index: number, tIcu: TIcu): void { tView.data[index] = tIcu; } else { ngDevMode && assertNodeType(tNode, TNodeType.IcuContainer); - tNode.value = tIcu as any; + tNode.value = tIcu; } } diff --git a/packages/core/src/render3/instructions/i18n_icu_container_visitor.ts b/packages/core/src/render3/instructions/i18n_icu_container_visitor.ts index 78c239d7cd..fbfe11ac8e 100644 --- a/packages/core/src/render3/instructions/i18n_icu_container_visitor.ts +++ b/packages/core/src/render3/instructions/i18n_icu_container_visitor.ts @@ -40,11 +40,8 @@ export function loadIcuContainerVisitor() { RNode | null { _lView = lView; while (_stack.length) _stack.pop(); - // FIXME(misko): This is a hack which allows us to associate `TI18n` with `TNode`. - // This should be refactored so that one can attach arbitrary data with `TNode` ngDevMode && assertTNodeForLView(tIcuContainerNode, lView); - const tIcu: TIcu = tIcuContainerNode.value as any; - enterIcu(tIcu, lView); + enterIcu(tIcuContainerNode.value, lView); return icuContainerIteratorNext; } diff --git a/packages/core/src/render3/interfaces/node.ts b/packages/core/src/render3/interfaces/node.ts index e682122031..d8a46638ea 100644 --- a/packages/core/src/render3/interfaces/node.ts +++ b/packages/core/src/render3/interfaces/node.ts @@ -434,7 +434,7 @@ export interface TNode { * `TNodeType.Element`: tag name * `TNodeType.ICUContainer`: `TIcu` */ - value: string|null; + value: any; /** * Attributes associated with an element. We need to store attributes to support various use-cases @@ -744,6 +744,11 @@ export interface TElementNode extends TNode { * a component without projection, it will be null. */ projection: (TNode|RNode[])[]|null; + + /** + * Stores TagName + */ + value: string; } /** Static data for a text node */ @@ -781,6 +786,7 @@ export interface TContainerNode extends TNode { parent: TElementNode|TElementContainerNode|null; tViews: TView|TView[]|null; projection: null; + value: null; } /** Static data for an */ @@ -801,8 +807,7 @@ export interface TIcuContainerNode extends TNode { parent: TElementNode|TElementContainerNode|null; tViews: null; projection: null; - // FIXME(misko): Refactor to enable the next line - // tagName: TIcu; + value: TIcu; } /** Static data for an LProjectionNode */ @@ -819,6 +824,7 @@ export interface TProjectionNode extends TNode { /** Index of the projection node. (See TNode.projection for more info.) */ projection: number; + value: null; } /**