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:
parent
2e237abb09
commit
d50df92568
|
@ -17,7 +17,7 @@ import {loadIcuContainerVisitor} from '../instructions/i18n_icu_container_visito
|
||||||
import {allocExpando, createTNodeAtIndex, elementAttributeInternal, setInputsForProperty, setNgReflectProperties} from '../instructions/shared';
|
import {allocExpando, createTNodeAtIndex, elementAttributeInternal, setInputsForProperty, setNgReflectProperties} from '../instructions/shared';
|
||||||
import {getDocument} from '../interfaces/document';
|
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 {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 {RComment, RElement} from '../interfaces/renderer';
|
||||||
import {SanitizerFn} from '../interfaces/sanitization';
|
import {SanitizerFn} from '../interfaces/sanitization';
|
||||||
import {HEADER_OFFSET, LView, TView} from '../interfaces/view';
|
import {HEADER_OFFSET, LView, TView} from '../interfaces/view';
|
||||||
|
|
|
@ -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
|
// 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
|
// will be just two cases which fits into the browser inline cache (inline cache can take up to
|
||||||
// 4)
|
// 4)
|
||||||
const tIcu: TIcu = value.hasOwnProperty('currentCaseLViewIndex') ?
|
const tIcu = value.hasOwnProperty('currentCaseLViewIndex') ? value as TIcu :
|
||||||
value :
|
(value as TIcuContainerNode).value;
|
||||||
(value as TIcuContainerNode).value as any;
|
|
||||||
ngDevMode && assertTIcu(tIcu);
|
ngDevMode && assertTIcu(tIcu);
|
||||||
return tIcu;
|
return tIcu;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +70,7 @@ export function setTIcu(tView: TView, index: number, tIcu: TIcu): void {
|
||||||
tView.data[index] = tIcu;
|
tView.data[index] = tIcu;
|
||||||
} else {
|
} else {
|
||||||
ngDevMode && assertNodeType(tNode, TNodeType.IcuContainer);
|
ngDevMode && assertNodeType(tNode, TNodeType.IcuContainer);
|
||||||
tNode.value = tIcu as any;
|
tNode.value = tIcu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,8 @@ export function loadIcuContainerVisitor() {
|
||||||
RNode | null {
|
RNode | null {
|
||||||
_lView = lView;
|
_lView = lView;
|
||||||
while (_stack.length) _stack.pop();
|
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);
|
ngDevMode && assertTNodeForLView(tIcuContainerNode, lView);
|
||||||
const tIcu: TIcu = tIcuContainerNode.value as any;
|
enterIcu(tIcuContainerNode.value, lView);
|
||||||
enterIcu(tIcu, lView);
|
|
||||||
return icuContainerIteratorNext;
|
return icuContainerIteratorNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,7 +434,7 @@ export interface TNode {
|
||||||
* `TNodeType.Element`: tag name
|
* `TNodeType.Element`: tag name
|
||||||
* `TNodeType.ICUContainer`: `TIcu`
|
* `TNodeType.ICUContainer`: `TIcu`
|
||||||
*/
|
*/
|
||||||
value: string|null;
|
value: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes associated with an element. We need to store attributes to support various use-cases
|
* 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.
|
* a component without projection, it will be null.
|
||||||
*/
|
*/
|
||||||
projection: (TNode|RNode[])[]|null;
|
projection: (TNode|RNode[])[]|null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores TagName
|
||||||
|
*/
|
||||||
|
value: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Static data for a text node */
|
/** Static data for a text node */
|
||||||
|
@ -781,6 +786,7 @@ export interface TContainerNode extends TNode {
|
||||||
parent: TElementNode|TElementContainerNode|null;
|
parent: TElementNode|TElementContainerNode|null;
|
||||||
tViews: TView|TView[]|null;
|
tViews: TView|TView[]|null;
|
||||||
projection: null;
|
projection: null;
|
||||||
|
value: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Static data for an <ng-container> */
|
/** Static data for an <ng-container> */
|
||||||
|
@ -801,8 +807,7 @@ export interface TIcuContainerNode extends TNode {
|
||||||
parent: TElementNode|TElementContainerNode|null;
|
parent: TElementNode|TElementContainerNode|null;
|
||||||
tViews: null;
|
tViews: null;
|
||||||
projection: null;
|
projection: null;
|
||||||
// FIXME(misko): Refactor to enable the next line
|
value: TIcu;
|
||||||
// tagName: TIcu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Static data for an LProjectionNode */
|
/** 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.) */
|
/** Index of the projection node. (See TNode.projection for more info.) */
|
||||||
projection: number;
|
projection: number;
|
||||||
|
value: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue