refactor(core): Remove `TViewNode` as it is no longer used. (#38707)
Previous commit change the logic to not rely on the `TViewNode` this change removes it entirely. PR Close #38707
This commit is contained in:
parent
eb32b6bd6b
commit
5db84d7221
|
@ -3,7 +3,7 @@
|
|||
"master": {
|
||||
"uncompressed": {
|
||||
"runtime-es2015": 1485,
|
||||
"main-es2015": 141711,
|
||||
"main-es2015": 140709,
|
||||
"polyfills-es2015": 36571
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
|||
"master": {
|
||||
"uncompressed": {
|
||||
"runtime-es2015": 1485,
|
||||
"main-es2015": 17362,
|
||||
"main-es2015": 16650,
|
||||
"polyfills-es2015": 36657
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
|||
"master": {
|
||||
"uncompressed": {
|
||||
"runtime-es2015": 1485,
|
||||
"main-es2015": 136168,
|
||||
"main-es2015": 134891,
|
||||
"polyfills-es2015": 37248
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,10 +218,9 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
|
|||
leaveView();
|
||||
}
|
||||
|
||||
const componentRef = new ComponentRef(
|
||||
return new ComponentRef(
|
||||
this.componentType, component,
|
||||
createElementRef(viewEngine_ElementRef, tElementNode, rootLView), rootLView, tElementNode);
|
||||
return componentRef;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import {executeCheckHooks, executeInitAndCheckHooks, incrementInitPhaseFlags} fr
|
|||
import {CONTAINER_HEADER_OFFSET, HAS_TRANSPLANTED_VIEWS, LContainer, MOVED_VIEWS} from '../interfaces/container';
|
||||
import {ComponentDef, ComponentTemplate, DirectiveDef, DirectiveDefListOrFactory, PipeDefListOrFactory, RenderFlags, ViewQueriesFunction} from '../interfaces/definition';
|
||||
import {INJECTOR_BLOOM_PARENT_SIZE, NodeInjectorFactory} from '../interfaces/injector';
|
||||
import {AttributeMarker, InitialInputData, InitialInputs, LocalRefExtractor, PropertyAliases, PropertyAliasValue, TAttributes, TConstantsOrFactory, TContainerNode, TDirectiveHostNode, TElementContainerNode, TElementNode, TIcuContainerNode, TNode, TNodeFlags, TNodeProviderIndexes, TNodeType, TProjectionNode, TViewNode} from '../interfaces/node';
|
||||
import {AttributeMarker, InitialInputData, InitialInputs, LocalRefExtractor, PropertyAliases, PropertyAliasValue, TAttributes, TConstantsOrFactory, TContainerNode, TDirectiveHostNode, TElementContainerNode, TElementNode, TIcuContainerNode, TNode, TNodeFlags, TNodeProviderIndexes, TNodeType, TProjectionNode} from '../interfaces/node';
|
||||
import {isProceduralRenderer, RComment, RElement, Renderer3, RendererFactory3, RNode, RText} from '../interfaces/renderer';
|
||||
import {SanitizerFn} from '../interfaces/sanitization';
|
||||
import {isComponentDef, isComponentHost, isContentQueryHost, isLContainer, isRootView} from '../interfaces/type_checks';
|
||||
|
@ -233,8 +233,8 @@ export function getOrCreateTNode(
|
|||
const tNode = tView.data[adjustedIndex] as TNode ||
|
||||
createTNodeAtIndex(tView, adjustedIndex, type, name, attrs);
|
||||
setPreviousOrParentTNode(tNode, true);
|
||||
return tNode as TElementNode & TViewNode & TContainerNode & TElementContainerNode &
|
||||
TProjectionNode & TIcuContainerNode;
|
||||
return tNode as TElementNode & TContainerNode & TElementContainerNode & TProjectionNode &
|
||||
TIcuContainerNode;
|
||||
}
|
||||
|
||||
function createTNodeAtIndex(
|
||||
|
@ -244,12 +244,7 @@ function createTNodeAtIndex(
|
|||
const isParent = getIsParent();
|
||||
const parent =
|
||||
isParent ? previousOrParentTNode : previousOrParentTNode && previousOrParentTNode.parent;
|
||||
// Parents cannot cross component boundaries because components will be used in multiple places,
|
||||
// so it's only set if the view is the same.
|
||||
// FIXME(misko): This check for `TNodeType.View` should not be needed. But removing it breaks DI,
|
||||
// so more investigation is needed.
|
||||
const parentInSameView = parent !== null && parent.type !== TNodeType.View;
|
||||
const tParentNode = parentInSameView ? parent as TElementNode | TContainerNode : null;
|
||||
// Parents cannot cross component boundaries because components will be used in multiple places.
|
||||
const tNode = tView.data[adjustedIndex] =
|
||||
createTNode(tView, parent as TElementNode | TContainerNode, type, adjustedIndex, name, attrs);
|
||||
// Assign a pointer to the first child node of a given view. The first node is not always the one
|
||||
|
@ -259,8 +254,7 @@ function createTNodeAtIndex(
|
|||
tView.firstChild = tNode;
|
||||
}
|
||||
if (previousOrParentTNode) {
|
||||
if (isParent && previousOrParentTNode.child == null &&
|
||||
(tNode.parent !== null || previousOrParentTNode.type === TNodeType.View)) {
|
||||
if (isParent && previousOrParentTNode.child == null && tNode.parent !== null) {
|
||||
// We are in the same view, which means we are adding content node to the parent view.
|
||||
previousOrParentTNode.child = tNode;
|
||||
} else if (!isParent) {
|
||||
|
@ -806,6 +800,24 @@ export function storeCleanupWithContext(
|
|||
* @param tViews Any TViews attached to this node
|
||||
* @returns the TNode object
|
||||
*/
|
||||
export function createTNode(
|
||||
tView: TView, tParent: TElementNode|TContainerNode|null, type: TNodeType.Container,
|
||||
adjustedIndex: number, tagName: string|null, attrs: TAttributes|null): TContainerNode;
|
||||
export function createTNode(
|
||||
tView: TView, tParent: TElementNode|TContainerNode|null, type: TNodeType.Element,
|
||||
adjustedIndex: number, tagName: string|null, attrs: TAttributes|null): TElementNode;
|
||||
export function createTNode(
|
||||
tView: TView, tParent: TElementNode|TContainerNode|null, type: TNodeType.ElementContainer,
|
||||
adjustedIndex: number, tagName: string|null, attrs: TAttributes|null): TElementContainerNode;
|
||||
export function createTNode(
|
||||
tView: TView, tParent: TElementNode|TContainerNode|null, type: TNodeType.IcuContainer,
|
||||
adjustedIndex: number, tagName: string|null, attrs: TAttributes|null): TIcuContainerNode;
|
||||
export function createTNode(
|
||||
tView: TView, tParent: TElementNode|TContainerNode|null, type: TNodeType.Projection,
|
||||
adjustedIndex: number, tagName: string|null, attrs: TAttributes|null): TProjectionNode;
|
||||
export function createTNode(
|
||||
tView: TView, tParent: TElementNode|TContainerNode|null, type: TNodeType, adjustedIndex: number,
|
||||
tagName: string|null, attrs: TAttributes|null): TNode;
|
||||
export function createTNode(
|
||||
tView: TView, tParent: TElementNode|TContainerNode|null, type: TNodeType, adjustedIndex: number,
|
||||
tagName: string|null, attrs: TAttributes|null): TNode {
|
||||
|
|
|
@ -9,14 +9,14 @@ import {assertFirstCreatePass} from '../assert';
|
|||
import {attachPatchData} from '../context_discovery';
|
||||
import {registerPostOrderHooks} from '../hooks';
|
||||
import {ComponentTemplate} from '../interfaces/definition';
|
||||
import {LocalRefExtractor, TAttributes, TContainerNode, TNodeType, TViewNode} from '../interfaces/node';
|
||||
import {LocalRefExtractor, TAttributes, TContainerNode, TNodeType} from '../interfaces/node';
|
||||
import {isDirectiveHost} from '../interfaces/type_checks';
|
||||
import {HEADER_OFFSET, LView, RENDERER, T_HOST, TView, TViewType} from '../interfaces/view';
|
||||
import {HEADER_OFFSET, LView, RENDERER, TView, TViewType} from '../interfaces/view';
|
||||
import {appendChild} from '../node_manipulation';
|
||||
import {getLView, getTView, setPreviousOrParentTNode} from '../state';
|
||||
import {getConstant} from '../util/view_utils';
|
||||
import {addToViewTree, createDirectivesInstances, createLContainer, createTView, getOrCreateTNode, resolveDirectives, saveResolvedLocalsInData} from './shared';
|
||||
|
||||
import {addToViewTree, createDirectivesInstances, createLContainer, createTNode, createTView, getOrCreateTNode, resolveDirectives, saveResolvedLocalsInData} from './shared';
|
||||
|
||||
|
||||
function templateFirstCreatePass(
|
||||
|
|
|
@ -24,22 +24,18 @@ export const enum TNodeType {
|
|||
* The TNode contains information about an `<ng-content>` projection
|
||||
*/
|
||||
Projection = 1,
|
||||
/**
|
||||
* The TNode contains information about an {@link LView}
|
||||
*/
|
||||
View = 2,
|
||||
/**
|
||||
* The TNode contains information about a DOM element aka {@link RNode}.
|
||||
*/
|
||||
Element = 3,
|
||||
Element = 2,
|
||||
/**
|
||||
* The TNode contains information about an `<ng-container>` element {@link RNode}.
|
||||
*/
|
||||
ElementContainer = 4,
|
||||
ElementContainer = 3,
|
||||
/**
|
||||
* The TNode contains information about an ICU comment used in `i18n`.
|
||||
*/
|
||||
IcuContainer = 5,
|
||||
IcuContainer = 4,
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,10 +45,9 @@ export const enum TNodeType {
|
|||
export const TNodeTypeAsString = [
|
||||
'Container', // 0
|
||||
'Projection', // 1
|
||||
'View', // 2
|
||||
'Element', // 3
|
||||
'ElementContainer', // 4
|
||||
'IcuContainer' // 5
|
||||
'Element', // 2
|
||||
'ElementContainer', // 3
|
||||
'IcuContainer' // 4
|
||||
] as const;
|
||||
|
||||
|
||||
|
@ -726,16 +721,6 @@ export interface TIcuContainerNode extends TNode {
|
|||
projection: null;
|
||||
}
|
||||
|
||||
/** Static data for a view */
|
||||
export interface TViewNode extends TNode {
|
||||
/** If -1, it's a dynamically created view. Otherwise, it is the view block ID. */
|
||||
index: number;
|
||||
child: TElementNode|TTextNode|TElementContainerNode|TContainerNode|TProjectionNode|null;
|
||||
parent: TContainerNode|null;
|
||||
tViews: null;
|
||||
projection: null;
|
||||
}
|
||||
|
||||
/** Static data for an LProjectionNode */
|
||||
export interface TProjectionNode extends TNode {
|
||||
/** Index in the data[] array */
|
||||
|
|
|
@ -15,7 +15,7 @@ import {Sanitizer} from '../../sanitization/sanitizer';
|
|||
import {LContainer} from './container';
|
||||
import {ComponentDef, ComponentTemplate, DirectiveDef, DirectiveDefList, HostBindingsFunction, PipeDef, PipeDefList, ViewQueriesFunction} from './definition';
|
||||
import {I18nUpdateOpCodes, TI18n} from './i18n';
|
||||
import {TConstants, TElementNode, TNode, TNodeTypeAsString, TViewNode} from './node';
|
||||
import {TConstants, TNode, TNodeTypeAsString} from './node';
|
||||
import {PlayerHandler} from './player';
|
||||
import {LQueries, TQueries} from './query';
|
||||
import {RComment, RElement, Renderer3, RendererFactory3} from './renderer';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {assertDefined, assertEqual} from '../util/assert';
|
||||
|
||||
import {TContainerNode, TElementContainerNode, TElementNode, TIcuContainerNode, TNode, TNodeType, TProjectionNode} from './interfaces/node';
|
||||
import {TContainerNode, TElementContainerNode, TElementNode, TIcuContainerNode, TNode, TNodeType, TNodeTypeAsString, TProjectionNode} from './interfaces/node';
|
||||
|
||||
export function assertNodeType(
|
||||
tNode: TNode, type: TNodeType.Container): asserts tNode is TContainerNode;
|
||||
|
@ -20,7 +20,6 @@ export function assertNodeType(
|
|||
tNode: TNode, type: TNodeType.IcuContainer): asserts tNode is TIcuContainerNode;
|
||||
export function assertNodeType(
|
||||
tNode: TNode, type: TNodeType.Projection): asserts tNode is TProjectionNode;
|
||||
export function assertNodeType(tNode: TNode, type: TNodeType.View): asserts tNode is TContainerNode;
|
||||
export function assertNodeType(tNode: TNode, type: TNodeType): asserts tNode is TNode {
|
||||
assertDefined(tNode, 'should be called with a TNode');
|
||||
assertEqual(tNode.type, type, `should be a ${typeName(type)}`);
|
||||
|
@ -46,11 +45,5 @@ export function assertNodeNotOfTypes(tNode: TNode, types: TNodeType[], message?:
|
|||
}
|
||||
|
||||
function typeName(type: TNodeType): string {
|
||||
if (type == TNodeType.Projection) return 'Projection';
|
||||
if (type == TNodeType.Container) return 'Container';
|
||||
if (type == TNodeType.IcuContainer) return 'IcuContainer';
|
||||
if (type == TNodeType.View) return 'View';
|
||||
if (type == TNodeType.Element) return 'Element';
|
||||
if (type == TNodeType.ElementContainer) return 'ElementContainer';
|
||||
return '<unknown>';
|
||||
return TNodeTypeAsString[type] || '<unknown>';
|
||||
}
|
||||
|
|
|
@ -9,48 +9,24 @@
|
|||
import {ViewEncapsulation} from '../metadata/view';
|
||||
import {Renderer2} from '../render/api';
|
||||
import {addToArray, removeFromArray} from '../util/array_utils';
|
||||
import {assertDefined, assertDomNode, assertEqual, assertSame, assertString} from '../util/assert';
|
||||
import {assertDefined, assertDomNode, assertEqual, assertString} from '../util/assert';
|
||||
|
||||
import {assertLContainer, assertLView, assertTNodeForLView} from './assert';
|
||||
import {attachPatchData} from './context_discovery';
|
||||
import {CONTAINER_HEADER_OFFSET, HAS_TRANSPLANTED_VIEWS, LContainer, MOVED_VIEWS, NATIVE, unusedValueExportToPlacateAjd as unused1} from './interfaces/container';
|
||||
import {ComponentDef} from './interfaces/definition';
|
||||
import {NodeInjectorFactory} from './interfaces/injector';
|
||||
import {TElementNode, TNode, TNodeFlags, TNodeType, TProjectionNode, TViewNode, unusedValueExportToPlacateAjd as unused2} from './interfaces/node';
|
||||
import {TElementNode, TNode, TNodeFlags, TNodeType, TProjectionNode, unusedValueExportToPlacateAjd as unused2} from './interfaces/node';
|
||||
import {unusedValueExportToPlacateAjd as unused3} from './interfaces/projection';
|
||||
import {isProceduralRenderer, ProceduralRenderer3, RElement, Renderer3, RNode, RText, unusedValueExportToPlacateAjd as unused4} from './interfaces/renderer';
|
||||
import {isLContainer, isLView} from './interfaces/type_checks';
|
||||
import {CHILD_HEAD, CLEANUP, DECLARATION_COMPONENT_VIEW, DECLARATION_LCONTAINER, DestroyHookData, FLAGS, HookData, HookFn, HOST, LView, LViewFlags, NEXT, PARENT, QUERIES, RENDERER, T_HOST, TVIEW, TView, TViewType, unusedValueExportToPlacateAjd as unused5} from './interfaces/view';
|
||||
import {assertNodeOfPossibleTypes, assertNodeType} from './node_assert';
|
||||
import {getLViewParent} from './util/view_traversal_utils';
|
||||
import {getNativeByTNode, getNonViewFirstChild, unwrapRNode, updateTransplantedViewCount} from './util/view_utils';
|
||||
import {getNativeByTNode, unwrapRNode, updateTransplantedViewCount} from './util/view_utils';
|
||||
|
||||
const unusedValueToPlacateAjd = unused1 + unused2 + unused3 + unused4 + unused5;
|
||||
|
||||
export function getLContainer(tNode: TViewNode, embeddedView: LView): LContainer|null {
|
||||
ngDevMode && assertLView(embeddedView);
|
||||
const container = embeddedView[PARENT] as LContainer;
|
||||
if (tNode.index === -1) {
|
||||
// This is a dynamically created view inside a dynamic container.
|
||||
// The parent isn't an LContainer if the embedded view hasn't been attached yet.
|
||||
return isLContainer(container) ? container : null;
|
||||
} else {
|
||||
ngDevMode && assertLContainer(container);
|
||||
// This is a inline view node (e.g. embeddedViewStart)
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves render parent for a given view.
|
||||
* Might be null if a view is not yet attached to any container.
|
||||
*/
|
||||
export function getContainerRenderParent(tViewNode: TViewNode, view: LView): RElement|null {
|
||||
const container = getLContainer(tViewNode, view);
|
||||
return container ? nativeParentNode(view[RENDERER], container[NATIVE]) : null;
|
||||
}
|
||||
|
||||
const enum WalkTNodeTreeAction {
|
||||
/** node create in the native environment. Run on initial creation. */
|
||||
Create = 0,
|
||||
|
@ -211,11 +187,15 @@ export function destroyViewTree(rootView: LView): void {
|
|||
// Only clean up view when moving to the side or up, as destroy hooks
|
||||
// should be called in order from the bottom up.
|
||||
while (lViewOrLContainer && !lViewOrLContainer![NEXT] && lViewOrLContainer !== rootView) {
|
||||
isLView(lViewOrLContainer) && cleanUpView(lViewOrLContainer[TVIEW], lViewOrLContainer);
|
||||
lViewOrLContainer = getParentState(lViewOrLContainer, rootView);
|
||||
if (isLView(lViewOrLContainer)) {
|
||||
cleanUpView(lViewOrLContainer[TVIEW], lViewOrLContainer);
|
||||
}
|
||||
lViewOrLContainer = lViewOrLContainer[PARENT];
|
||||
}
|
||||
if (lViewOrLContainer === null) lViewOrLContainer = rootView;
|
||||
isLView(lViewOrLContainer) && cleanUpView(lViewOrLContainer[TVIEW], lViewOrLContainer);
|
||||
if (isLView(lViewOrLContainer)) {
|
||||
cleanUpView(lViewOrLContainer[TVIEW], lViewOrLContainer);
|
||||
}
|
||||
next = lViewOrLContainer && lViewOrLContainer![NEXT];
|
||||
}
|
||||
lViewOrLContainer = next;
|
||||
|
@ -381,32 +361,6 @@ export function destroyLView(tView: TView, lView: LView) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which LViewOrLContainer to jump to when traversing back up the
|
||||
* tree in destroyViewTree.
|
||||
*
|
||||
* Normally, the view's parent LView should be checked, but in the case of
|
||||
* embedded views, the container (which is the view node's parent, but not the
|
||||
* LView's parent) needs to be checked for a possible next property.
|
||||
*
|
||||
* @param lViewOrLContainer The LViewOrLContainer for which we need a parent state
|
||||
* @param rootView The rootView, so we don't propagate too far up the view tree
|
||||
* @returns The correct parent LViewOrLContainer
|
||||
*/
|
||||
export function getParentState(lViewOrLContainer: LView|LContainer, rootView: LView): LView|
|
||||
LContainer|null {
|
||||
let tNode;
|
||||
if (isLView(lViewOrLContainer) && (tNode = lViewOrLContainer[T_HOST]) &&
|
||||
tNode.type === TNodeType.View) {
|
||||
// if it's an embedded view, the state needs to go up to the container, in case the
|
||||
// container has a next
|
||||
return getLContainer(tNode as TViewNode, lViewOrLContainer);
|
||||
} else {
|
||||
// otherwise, use parent view for containers or component views
|
||||
return lViewOrLContainer[PARENT] === rootView ? null : lViewOrLContainer[PARENT];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls onDestroys hooks for all directives and pipes in a given view and then removes all
|
||||
* listeners. Listeners are removed as the last step so events delivered in the onDestroys hooks
|
||||
|
@ -531,7 +485,7 @@ function getRenderParent(tView: TView, tNode: TNode, currentView: LView): REleme
|
|||
// can't be used as a render parent.
|
||||
let parentTNode = tNode.parent;
|
||||
while (parentTNode != null &&
|
||||
(parentTNode.type === TNodeType.ElementContainer || parentTNode.type === TNodeType.View ||
|
||||
(parentTNode.type === TNodeType.ElementContainer ||
|
||||
parentTNode.type === TNodeType.IcuContainer)) {
|
||||
tNode = parentTNode;
|
||||
parentTNode = tNode.parent;
|
||||
|
@ -539,22 +493,10 @@ function getRenderParent(tView: TView, tNode: TNode, currentView: LView): REleme
|
|||
|
||||
// If the parent tNode is null, then we are inserting across views: either into an embedded view
|
||||
// or a component view.
|
||||
if (parentTNode == null) {
|
||||
const hostTNode = currentView[T_HOST]!;
|
||||
if (hostTNode && hostTNode.type === TNodeType.View) {
|
||||
// We are inserting a root element of an embedded view We might delay insertion of children
|
||||
// for a given view if it is disconnected. This might happen for 2 main reasons:
|
||||
// - view is not inserted into any container(view was created but not inserted yet)
|
||||
// - view is inserted into a container but the container itself is not inserted into the DOM
|
||||
// (container might be part of projection or child of a view that is not inserted yet).
|
||||
// In other words we can insert children of a given view if this view was inserted into a
|
||||
// container and the container itself has its render parent determined.
|
||||
return getContainerRenderParent(hostTNode as TViewNode, currentView);
|
||||
} else {
|
||||
if (parentTNode === null) {
|
||||
// We are inserting a root element of the component view into the component host element and
|
||||
// it should always be eager.
|
||||
return currentView[HOST];
|
||||
}
|
||||
} else {
|
||||
const isIcuCase = tNode && tNode.type === TNodeType.IcuContainer;
|
||||
// If the parent of this node is an ICU container, then it is represented by comment node and we
|
||||
|
@ -650,13 +592,7 @@ export function nativeNextSibling(renderer: Renderer3, node: RNode): RNode|null
|
|||
* @param lView
|
||||
*/
|
||||
function getNativeAnchorNode(parentTNode: TNode, lView: LView): RNode|null {
|
||||
if (parentTNode.type === TNodeType.View) {
|
||||
const lContainer = getLContainer(parentTNode as TViewNode, lView);
|
||||
if (lContainer === null) return null;
|
||||
const index = lContainer.indexOf(lView, CONTAINER_HEADER_OFFSET) - CONTAINER_HEADER_OFFSET;
|
||||
return getBeforeNodeForView(index, lContainer);
|
||||
} else if (
|
||||
parentTNode.type === TNodeType.ElementContainer ||
|
||||
if (parentTNode.type === TNodeType.ElementContainer ||
|
||||
parentTNode.type === TNodeType.IcuContainer) {
|
||||
return getNativeByTNode(parentTNode, lView);
|
||||
}
|
||||
|
@ -743,7 +679,7 @@ export function getBeforeNodeForView(viewIndexInContainer: number, lContainer: L
|
|||
const nextViewIndex = CONTAINER_HEADER_OFFSET + viewIndexInContainer + 1;
|
||||
if (nextViewIndex < lContainer.length) {
|
||||
const lView = lContainer[nextViewIndex] as LView;
|
||||
const firstTNodeOfView = getNonViewFirstChild(lView[TVIEW]);
|
||||
const firstTNodeOfView = lView[TVIEW].firstChild;
|
||||
if (firstTNodeOfView !== null) {
|
||||
return getFirstNativeNode(lView, firstTNodeOfView);
|
||||
}
|
||||
|
|
|
@ -48,19 +48,19 @@ export function ɵɵpipe(index: number, pipeName: string): any {
|
|||
|
||||
const pipeFactory = pipeDef.factory || (pipeDef.factory = getFactoryDef(pipeDef.type, true));
|
||||
const previousInjectImplementation = setInjectImplementation(ɵɵdirectiveInject);
|
||||
let pipeInstance: any;
|
||||
|
||||
try {
|
||||
// DI for pipes is supposed to behave like directives when placed on a component
|
||||
// host node, which means that we have to disable access to `viewProviders`.
|
||||
const previousIncludeViewProviders = setIncludeViewProviders(false);
|
||||
pipeInstance = pipeFactory();
|
||||
const pipeInstance = pipeFactory();
|
||||
setIncludeViewProviders(previousIncludeViewProviders);
|
||||
} finally {
|
||||
setInjectImplementation(previousInjectImplementation);
|
||||
}
|
||||
store(tView, getLView(), index, pipeInstance);
|
||||
return pipeInstance;
|
||||
} finally {
|
||||
// we have to restore the injector implementation in finally, just in case the creation of the
|
||||
// pipe throws an error.
|
||||
setInjectImplementation(previousInjectImplementation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -207,17 +207,3 @@ export function updateTransplantedViewCount(lContainer: LContainer, amount: 1|-
|
|||
parent = parent[PARENT];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the `TView.firstChild` and unwraps if it is `TNodeType.View`.
|
||||
*
|
||||
* We are inconsistent about the way we store root of Views. Embedded views have `TNodeType.View` in
|
||||
* the root but component views do not. A lot of logic does not expect to see `TNodeType.View` and
|
||||
* crashes on it, so we unwrap it.
|
||||
*/
|
||||
export function getNonViewFirstChild(tView: TView): TNode|null {
|
||||
// FIXME(misko): Delete me! (as TNodeType.View no longer exists)
|
||||
const firstChild = tView.firstChild;
|
||||
return firstChild === null ? null :
|
||||
(firstChild.type === TNodeType.View ? firstChild.child : firstChild);
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@ import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, InternalViewRef as viewEn
|
|||
import {assertDefined} from '../util/assert';
|
||||
import {checkNoChangesInRootView, checkNoChangesInternal, detectChangesInRootView, detectChangesInternal, markViewDirty, storeCleanupWithContext} from './instructions/shared';
|
||||
import {CONTAINER_HEADER_OFFSET} from './interfaces/container';
|
||||
import {TElementNode, TNode, TNodeType, TViewNode} from './interfaces/node';
|
||||
import {TElementNode, TNode, TNodeType} from './interfaces/node';
|
||||
import {isLContainer} from './interfaces/type_checks';
|
||||
import {CONTEXT, DECLARATION_COMPONENT_VIEW, FLAGS, HOST, LView, LViewFlags, T_HOST, TVIEW, TView} from './interfaces/view';
|
||||
import {assertNodeOfPossibleTypes} from './node_assert';
|
||||
import {destroyLView, renderDetachView} from './node_manipulation';
|
||||
import {getLViewParent} from './util/view_traversal_utils';
|
||||
import {getNonViewFirstChild, unwrapRNode} from './util/view_utils';
|
||||
import {unwrapRNode} from './util/view_utils';
|
||||
|
||||
|
||||
|
||||
|
@ -337,7 +337,7 @@ function collectNativeNodes(
|
|||
if (isLContainer(lNode)) {
|
||||
for (let i = CONTAINER_HEADER_OFFSET; i < lNode.length; i++) {
|
||||
const lViewInAContainer = lNode[i];
|
||||
const lViewFirstChildTNode = getNonViewFirstChild(lViewInAContainer[TVIEW]);
|
||||
const lViewFirstChildTNode = lViewInAContainer[TVIEW].firstChild;
|
||||
if (lViewFirstChildTNode !== null) {
|
||||
collectNativeNodes(
|
||||
lViewInAContainer[TVIEW], lViewInAContainer, lViewFirstChildTNode, result);
|
||||
|
|
|
@ -176,9 +176,6 @@
|
|||
{
|
||||
"name": "getIsParent"
|
||||
},
|
||||
{
|
||||
"name": "getLContainer"
|
||||
},
|
||||
{
|
||||
"name": "getLView"
|
||||
},
|
||||
|
@ -251,9 +248,6 @@
|
|||
{
|
||||
"name": "isInlineTemplate"
|
||||
},
|
||||
{
|
||||
"name": "isLContainer"
|
||||
},
|
||||
{
|
||||
"name": "isNodeMatchingSelector"
|
||||
},
|
||||
|
@ -350,9 +344,6 @@
|
|||
{
|
||||
"name": "setUpAttributes"
|
||||
},
|
||||
{
|
||||
"name": "unwrapRNode"
|
||||
},
|
||||
{
|
||||
"name": "updateTransplantedViewCount"
|
||||
},
|
||||
|
|
|
@ -950,9 +950,6 @@
|
|||
{
|
||||
"name": "generatePropertyAliases"
|
||||
},
|
||||
{
|
||||
"name": "getBeforeNodeForView"
|
||||
},
|
||||
{
|
||||
"name": "getCheckNoChangesMode"
|
||||
},
|
||||
|
@ -995,9 +992,6 @@
|
|||
{
|
||||
"name": "getLCleanup"
|
||||
},
|
||||
{
|
||||
"name": "getLContainer"
|
||||
},
|
||||
{
|
||||
"name": "getLView"
|
||||
},
|
||||
|
@ -1022,9 +1016,6 @@
|
|||
{
|
||||
"name": "getNodeInjectable"
|
||||
},
|
||||
{
|
||||
"name": "getNonViewFirstChild"
|
||||
},
|
||||
{
|
||||
"name": "getNullInjector"
|
||||
},
|
||||
|
@ -1055,9 +1046,6 @@
|
|||
{
|
||||
"name": "getParentInjectorView"
|
||||
},
|
||||
{
|
||||
"name": "getParentState"
|
||||
},
|
||||
{
|
||||
"name": "getPlatform"
|
||||
},
|
||||
|
|
|
@ -107,9 +107,6 @@
|
|||
{
|
||||
"name": "extractPipeDef"
|
||||
},
|
||||
{
|
||||
"name": "getBeforeNodeForView"
|
||||
},
|
||||
{
|
||||
"name": "getCheckNoChangesMode"
|
||||
},
|
||||
|
@ -125,9 +122,6 @@
|
|||
{
|
||||
"name": "getFirstLContainer"
|
||||
},
|
||||
{
|
||||
"name": "getLContainer"
|
||||
},
|
||||
{
|
||||
"name": "getNativeByTNode"
|
||||
},
|
||||
|
@ -164,9 +158,6 @@
|
|||
{
|
||||
"name": "invertObject"
|
||||
},
|
||||
{
|
||||
"name": "isLContainer"
|
||||
},
|
||||
{
|
||||
"name": "isProceduralRenderer"
|
||||
},
|
||||
|
@ -227,16 +218,10 @@
|
|||
{
|
||||
"name": "setSelectedIndex"
|
||||
},
|
||||
{
|
||||
"name": "unwrapRNode"
|
||||
},
|
||||
{
|
||||
"name": "updateTransplantedViewCount"
|
||||
},
|
||||
{
|
||||
"name": "viewAttachedToChangeDetector"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵtext"
|
||||
}
|
||||
]
|
|
@ -1259,9 +1259,6 @@
|
|||
{
|
||||
"name": "getAppInitializer"
|
||||
},
|
||||
{
|
||||
"name": "getBeforeNodeForView"
|
||||
},
|
||||
{
|
||||
"name": "getBootstrapListener"
|
||||
},
|
||||
|
@ -1319,9 +1316,6 @@
|
|||
{
|
||||
"name": "getLCleanup"
|
||||
},
|
||||
{
|
||||
"name": "getLContainer"
|
||||
},
|
||||
{
|
||||
"name": "getLView"
|
||||
},
|
||||
|
@ -1346,9 +1340,6 @@
|
|||
{
|
||||
"name": "getNodeInjectable"
|
||||
},
|
||||
{
|
||||
"name": "getNonViewFirstChild"
|
||||
},
|
||||
{
|
||||
"name": "getNullInjector"
|
||||
},
|
||||
|
@ -1385,9 +1376,6 @@
|
|||
{
|
||||
"name": "getParentInjectorView"
|
||||
},
|
||||
{
|
||||
"name": "getParentState"
|
||||
},
|
||||
{
|
||||
"name": "getPath"
|
||||
},
|
||||
|
|
|
@ -329,9 +329,6 @@
|
|||
{
|
||||
"name": "generatePropertyAliases"
|
||||
},
|
||||
{
|
||||
"name": "getBeforeNodeForView"
|
||||
},
|
||||
{
|
||||
"name": "getCheckNoChangesMode"
|
||||
},
|
||||
|
@ -362,9 +359,6 @@
|
|||
{
|
||||
"name": "getLCleanup"
|
||||
},
|
||||
{
|
||||
"name": "getLContainer"
|
||||
},
|
||||
{
|
||||
"name": "getLView"
|
||||
},
|
||||
|
@ -386,9 +380,6 @@
|
|||
{
|
||||
"name": "getNodeInjectable"
|
||||
},
|
||||
{
|
||||
"name": "getNonViewFirstChild"
|
||||
},
|
||||
{
|
||||
"name": "getOrCreateInjectable"
|
||||
},
|
||||
|
@ -416,9 +407,6 @@
|
|||
{
|
||||
"name": "getParentInjectorView"
|
||||
},
|
||||
{
|
||||
"name": "getParentState"
|
||||
},
|
||||
{
|
||||
"name": "getPreviousIndex"
|
||||
},
|
||||
|
|
|
@ -13,7 +13,6 @@ describe('node interfaces', () => {
|
|||
it('should agree with TNodeTypeAsString', () => {
|
||||
expect(TNodeTypeAsString[TNodeType.Container]).toEqual('Container');
|
||||
expect(TNodeTypeAsString[TNodeType.Projection]).toEqual('Projection');
|
||||
expect(TNodeTypeAsString[TNodeType.View]).toEqual('View');
|
||||
expect(TNodeTypeAsString[TNodeType.Element]).toEqual('Element');
|
||||
expect(TNodeTypeAsString[TNodeType.ElementContainer]).toEqual('ElementContainer');
|
||||
expect(TNodeTypeAsString[TNodeType.IcuContainer]).toEqual('IcuContainer');
|
||||
|
|
|
@ -10,7 +10,7 @@ import {LViewFlags, TViewType} from '@angular/core/src/render3/interfaces/view';
|
|||
import {ɵɵdefineDirective, ɵɵelementEnd, ɵɵelementStart, ɵɵtext} from '../../../../src/render3/index';
|
||||
import {createLView, createTNode, createTView} from '../../../../src/render3/instructions/shared';
|
||||
import {RenderFlags} from '../../../../src/render3/interfaces/definition';
|
||||
import {TNodeType, TViewNode} from '../../../../src/render3/interfaces/node';
|
||||
import {TNodeType} from '../../../../src/render3/interfaces/node';
|
||||
import {createBenchmark} from '../micro_bench';
|
||||
import {createAndRenderLView} from '../setup';
|
||||
|
||||
|
@ -78,7 +78,7 @@ const rootLView = createLView(
|
|||
null, createTView(TViewType.Root, null, null, 0, 0, null, null, null, null, null), {},
|
||||
LViewFlags.IsRoot, null, null, null, null, null, null);
|
||||
|
||||
const viewTNode = createTNode(null!, null, TNodeType.View, -1, null, null) as TViewNode;
|
||||
const viewTNode = createTNode(null!, null, TNodeType.Element, -1, null, null);
|
||||
const embeddedTView = createTView(
|
||||
TViewType.Embedded, null, testTemplate, 21, 10, [Tooltip.ɵdir], null, null, null,
|
||||
[['position', 'top', 3, 'tooltip']]);
|
||||
|
|
|
@ -9,7 +9,7 @@ import {ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/instruct
|
|||
import {createLView, createTNode, createTView} from '../../../../src/render3/instructions/shared';
|
||||
import {ɵɵtext} from '../../../../src/render3/instructions/text';
|
||||
import {RenderFlags} from '../../../../src/render3/interfaces/definition';
|
||||
import {TNodeType, TViewNode} from '../../../../src/render3/interfaces/node';
|
||||
import {TNodeType} from '../../../../src/render3/interfaces/node';
|
||||
import {LViewFlags, TViewType} from '../../../../src/render3/interfaces/view';
|
||||
import {createBenchmark} from '../micro_bench';
|
||||
import {createAndRenderLView} from '../setup';
|
||||
|
@ -67,7 +67,7 @@ const rootLView = createLView(
|
|||
null, createTView(TViewType.Root, null, null, 0, 0, null, null, null, null, null), {},
|
||||
LViewFlags.IsRoot, null, null, null, null, null, null);
|
||||
|
||||
const viewTNode = createTNode(null!, null, TNodeType.View, -1, null, null) as TViewNode;
|
||||
const viewTNode = createTNode(null!, null, TNodeType.Element, -1, null, null);
|
||||
const embeddedTView = createTView(
|
||||
TViewType.Embedded, null, testTemplate, 21, 0, null, null, null, null, [[
|
||||
'name1', 'value1', 'name2', 'value2', 'name3', 'value3', 'name4', 'value4', 'name5', 'value5'
|
||||
|
|
|
@ -9,7 +9,7 @@ import {ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/instruct
|
|||
import {ɵɵlistener} from '../../../../src/render3/instructions/listener';
|
||||
import {createLView, createTNode, createTView} from '../../../../src/render3/instructions/shared';
|
||||
import {RenderFlags} from '../../../../src/render3/interfaces/definition';
|
||||
import {TNodeType, TViewNode} from '../../../../src/render3/interfaces/node';
|
||||
import {TNodeType} from '../../../../src/render3/interfaces/node';
|
||||
import {LViewFlags, TViewType} from '../../../../src/render3/interfaces/view';
|
||||
import {createBenchmark} from '../micro_bench';
|
||||
import {createAndRenderLView} from '../setup';
|
||||
|
@ -69,7 +69,7 @@ const rootLView = createLView(
|
|||
null, createTView(TViewType.Root, null, null, 0, 0, null, null, null, null, null), {},
|
||||
LViewFlags.IsRoot, null, null, null, null, null, null);
|
||||
|
||||
const viewTNode = createTNode(null!, null, TNodeType.View, -1, null, null) as TViewNode;
|
||||
const viewTNode = createTNode(null!, null, TNodeType.Element, -1, null, null);
|
||||
const embeddedTView = createTView(
|
||||
TViewType.Embedded, null, testTemplate, 11, 0, null, null, null, null, [[3, 'click', 'input']]);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import {ElementRef, TemplateRef, ViewContainerRef} from '../../../../src/linker'
|
|||
import {ɵɵdefineDirective, ɵɵdirectiveInject, ɵɵtemplate} from '../../../../src/render3/index';
|
||||
import {createLView, createTNode, createTView} from '../../../../src/render3/instructions/shared';
|
||||
import {RenderFlags} from '../../../../src/render3/interfaces/definition';
|
||||
import {TNodeType, TViewNode} from '../../../../src/render3/interfaces/node';
|
||||
import {TNodeType} from '../../../../src/render3/interfaces/node';
|
||||
import {LViewFlags, TViewType} from '../../../../src/render3/interfaces/view';
|
||||
import {injectTemplateRef, injectViewContainerRef} from '../../../../src/render3/view_engine_compatibility';
|
||||
import {createBenchmark} from '../micro_bench';
|
||||
|
@ -62,7 +62,7 @@ const rootLView = createLView(
|
|||
null, createTView(TViewType.Root, null, null, 0, 0, null, null, null, null, null), {},
|
||||
LViewFlags.IsRoot, null, null, null, null, null, null);
|
||||
|
||||
const viewTNode = createTNode(null!, null, TNodeType.View, -1, null, null) as TViewNode;
|
||||
const viewTNode = createTNode(null!, null, TNodeType.Element, -1, null, null);
|
||||
const embeddedTView = createTView(
|
||||
TViewType.Root, null, testTemplate, 2, 0, [NgIfLike.ɵdir], null, null, null,
|
||||
[['viewManipulation', '']]);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
import {addToViewTree, createLContainer, createLView, createTNode, createTView, getOrCreateTNode, refreshView, renderView} from '../../../src/render3/instructions/shared';
|
||||
import {ComponentTemplate, DirectiveDefList} from '../../../src/render3/interfaces/definition';
|
||||
import {TAttributes, TNodeType, TViewNode} from '../../../src/render3/interfaces/node';
|
||||
import {TAttributes, TElementNode, TNodeType} from '../../../src/render3/interfaces/node';
|
||||
import {domRendererFactory3, RendererFactory3} from '../../../src/render3/interfaces/renderer';
|
||||
import {LView, LViewFlags, TVIEW, TView, TViewType} from '../../../src/render3/interfaces/view';
|
||||
import {insertView} from '../../../src/render3/node_manipulation';
|
||||
|
@ -20,7 +20,7 @@ const rendererFactory: RendererFactory3 =
|
|||
const renderer = rendererFactory.createRenderer(null, null);
|
||||
|
||||
export function createAndRenderLView(
|
||||
parentLView: LView, tView: TView, hostTNode: TViewNode): LView {
|
||||
parentLView: LView, tView: TView, hostTNode: TElementNode): LView {
|
||||
const embeddedLView = createLView(
|
||||
parentLView, tView, {}, LViewFlags.CheckAlways, null, hostTNode, rendererFactory, renderer,
|
||||
null, null);
|
||||
|
@ -66,7 +66,7 @@ export function setupTestHarness(
|
|||
const embeddedTView = createTView(
|
||||
TViewType.Embedded, null, templateFn, decls, vars, directiveRegistry, null, null, null,
|
||||
consts);
|
||||
const viewTNode = createTNode(hostTView, null, TNodeType.View, -1, null, null) as TViewNode;
|
||||
const viewTNode = createTNode(hostTView, null, TNodeType.Element, -1, null, null);
|
||||
|
||||
function createEmbeddedLView(): LView {
|
||||
const embeddedLView = createLView(
|
||||
|
|
|
@ -11,7 +11,7 @@ import {LViewFlags, TViewType} from '@angular/core/src/render3/interfaces/view';
|
|||
import {ɵɵdefineDirective, ɵɵelement, ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/index';
|
||||
import {createLView, createTNode, createTView} from '../../../../src/render3/instructions/shared';
|
||||
import {RenderFlags} from '../../../../src/render3/interfaces/definition';
|
||||
import {TNodeType, TViewNode} from '../../../../src/render3/interfaces/node';
|
||||
import {TNodeType} from '../../../../src/render3/interfaces/node';
|
||||
import {destroyLView} from '../../../../src/render3/node_manipulation';
|
||||
import {createBenchmark} from '../micro_bench';
|
||||
import {createAndRenderLView} from '../setup';
|
||||
|
@ -55,7 +55,7 @@ const rootLView = createLView(
|
|||
null, createTView(TViewType.Root, null, null, 0, 0, null, null, null, null, null), {},
|
||||
LViewFlags.IsRoot, null, null, null, null, null, null);
|
||||
|
||||
const viewTNode = createTNode(null!, null, TNodeType.View, -1, null, null) as TViewNode;
|
||||
const viewTNode = createTNode(null!, null, TNodeType.Element, -1, null, null);
|
||||
const embeddedTView = createTView(
|
||||
TViewType.Embedded, null, testTemplate, 21, 10, [ToDestroy.ɵdir], null, null, null,
|
||||
[['to-destroy']]);
|
||||
|
|
Loading…
Reference in New Issue