refactor(core): Remove hack where we `TIcu` was stored in `tagName` (#39233)

Remove casting where we stored `TIcu` in `TNode.tagName` which was of
type `string` rather than `TIcu'. (renamed to `TNode.value` in previous
commit.)

PR Close #39233
This commit is contained in:
Misko Hevery 2020-10-12 17:17:11 -07:00 committed by Alex Rickabaugh
parent 2e237abb09
commit d50df92568
4 changed files with 14 additions and 12 deletions

View File

@ -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';

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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 <ng-container> */
@ -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;
}
/**