diff --git a/goldens/size-tracking/integration-payloads.json b/goldens/size-tracking/integration-payloads.json index 0f7bb8c115..1d090774b3 100644 --- a/goldens/size-tracking/integration-payloads.json +++ b/goldens/size-tracking/integration-payloads.json @@ -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 } } diff --git a/packages/core/src/render3/component_ref.ts b/packages/core/src/render3/component_ref.ts index 8ef0a9b537..a12fe44d46 100644 --- a/packages/core/src/render3/component_ref.ts +++ b/packages/core/src/render3/component_ref.ts @@ -218,10 +218,9 @@ export class ComponentFactory extends viewEngine_ComponentFactory { leaveView(); } - const componentRef = new ComponentRef( + return new ComponentRef( this.componentType, component, createElementRef(viewEngine_ElementRef, tElementNode, rootLView), rootLView, tElementNode); - return componentRef; } } diff --git a/packages/core/src/render3/instructions/shared.ts b/packages/core/src/render3/instructions/shared.ts index d4226fe72d..0bab24b511 100644 --- a/packages/core/src/render3/instructions/shared.ts +++ b/packages/core/src/render3/instructions/shared.ts @@ -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 { diff --git a/packages/core/src/render3/instructions/template.ts b/packages/core/src/render3/instructions/template.ts index 1bfacec8d7..6ac37b5ff0 100644 --- a/packages/core/src/render3/instructions/template.ts +++ b/packages/core/src/render3/instructions/template.ts @@ -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( diff --git a/packages/core/src/render3/interfaces/node.ts b/packages/core/src/render3/interfaces/node.ts index 22d9744786..67b6efd229 100644 --- a/packages/core/src/render3/interfaces/node.ts +++ b/packages/core/src/render3/interfaces/node.ts @@ -24,22 +24,18 @@ export const enum TNodeType { * The TNode contains information about an `` 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 `` 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 */ diff --git a/packages/core/src/render3/interfaces/view.ts b/packages/core/src/render3/interfaces/view.ts index 8ee233cb7b..b6369284b5 100644 --- a/packages/core/src/render3/interfaces/view.ts +++ b/packages/core/src/render3/interfaces/view.ts @@ -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'; diff --git a/packages/core/src/render3/node_assert.ts b/packages/core/src/render3/node_assert.ts index 59714e88df..9c64ee6a61 100644 --- a/packages/core/src/render3/node_assert.ts +++ b/packages/core/src/render3/node_assert.ts @@ -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 ''; + return TNodeTypeAsString[type] || ''; } diff --git a/packages/core/src/render3/node_manipulation.ts b/packages/core/src/render3/node_manipulation.ts index 3d5aa10979..44fe80c781 100644 --- a/packages/core/src/render3/node_manipulation.ts +++ b/packages/core/src/render3/node_manipulation.ts @@ -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 { - // We are inserting a root element of the component view into the component host element and - // it should always be eager. - return currentView[HOST]; - } + 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); } diff --git a/packages/core/src/render3/pipe.ts b/packages/core/src/render3/pipe.ts index 55cfe61864..8afba415db 100644 --- a/packages/core/src/render3/pipe.ts +++ b/packages/core/src/render3/pipe.ts @@ -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); + 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); } - store(tView, getLView(), index, pipeInstance); - return pipeInstance; } /** diff --git a/packages/core/src/render3/util/view_utils.ts b/packages/core/src/render3/util/view_utils.ts index f86c85d019..5aa43295bc 100644 --- a/packages/core/src/render3/util/view_utils.ts +++ b/packages/core/src/render3/util/view_utils.ts @@ -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); -} diff --git a/packages/core/src/render3/view_ref.ts b/packages/core/src/render3/view_ref.ts index 688d4774de..5977e5c973 100644 --- a/packages/core/src/render3/view_ref.ts +++ b/packages/core/src/render3/view_ref.ts @@ -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); diff --git a/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json b/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json index 8e89517914..83f93b4d57 100644 --- a/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json +++ b/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json @@ -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" }, diff --git a/packages/core/test/bundling/forms/bundle.golden_symbols.json b/packages/core/test/bundling/forms/bundle.golden_symbols.json index f474a0e612..b90c06b7c7 100644 --- a/packages/core/test/bundling/forms/bundle.golden_symbols.json +++ b/packages/core/test/bundling/forms/bundle.golden_symbols.json @@ -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" }, diff --git a/packages/core/test/bundling/hello_world/bundle.golden_symbols.json b/packages/core/test/bundling/hello_world/bundle.golden_symbols.json index afbed9a415..6b53602948 100644 --- a/packages/core/test/bundling/hello_world/bundle.golden_symbols.json +++ b/packages/core/test/bundling/hello_world/bundle.golden_symbols.json @@ -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" } ] \ No newline at end of file diff --git a/packages/core/test/bundling/router/bundle.golden_symbols.json b/packages/core/test/bundling/router/bundle.golden_symbols.json index 88b6a1db64..9c647c6254 100644 --- a/packages/core/test/bundling/router/bundle.golden_symbols.json +++ b/packages/core/test/bundling/router/bundle.golden_symbols.json @@ -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" }, diff --git a/packages/core/test/bundling/todo/bundle.golden_symbols.json b/packages/core/test/bundling/todo/bundle.golden_symbols.json index 30cd8d19a4..12e933f6b7 100644 --- a/packages/core/test/bundling/todo/bundle.golden_symbols.json +++ b/packages/core/test/bundling/todo/bundle.golden_symbols.json @@ -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" }, diff --git a/packages/core/test/render3/interfaces/node_spec.ts b/packages/core/test/render3/interfaces/node_spec.ts index cd2a3a1516..e30cb5c5fe 100644 --- a/packages/core/test/render3/interfaces/node_spec.ts +++ b/packages/core/test/render3/interfaces/node_spec.ts @@ -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'); diff --git a/packages/core/test/render3/perf/directive_instantiate/index.ts b/packages/core/test/render3/perf/directive_instantiate/index.ts index d27206f88a..dd6dba1bd1 100644 --- a/packages/core/test/render3/perf/directive_instantiate/index.ts +++ b/packages/core/test/render3/perf/directive_instantiate/index.ts @@ -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']]); diff --git a/packages/core/test/render3/perf/element_text_create/index.ts b/packages/core/test/render3/perf/element_text_create/index.ts index b076c8ebd7..bc7d7d6b91 100644 --- a/packages/core/test/render3/perf/element_text_create/index.ts +++ b/packages/core/test/render3/perf/element_text_create/index.ts @@ -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' diff --git a/packages/core/test/render3/perf/listeners/index.ts b/packages/core/test/render3/perf/listeners/index.ts index 3bd64a4346..834483b2ff 100644 --- a/packages/core/test/render3/perf/listeners/index.ts +++ b/packages/core/test/render3/perf/listeners/index.ts @@ -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']]); diff --git a/packages/core/test/render3/perf/ng_template/index.ts b/packages/core/test/render3/perf/ng_template/index.ts index fe8153dc64..50adf84370 100644 --- a/packages/core/test/render3/perf/ng_template/index.ts +++ b/packages/core/test/render3/perf/ng_template/index.ts @@ -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', '']]); diff --git a/packages/core/test/render3/perf/setup.ts b/packages/core/test/render3/perf/setup.ts index 6ac22272e2..60043f1a2f 100644 --- a/packages/core/test/render3/perf/setup.ts +++ b/packages/core/test/render3/perf/setup.ts @@ -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( diff --git a/packages/core/test/render3/perf/view_destroy_hook/index.ts b/packages/core/test/render3/perf/view_destroy_hook/index.ts index b0dfd5059a..8c3fe61b62 100644 --- a/packages/core/test/render3/perf/view_destroy_hook/index.ts +++ b/packages/core/test/render3/perf/view_destroy_hook/index.ts @@ -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']]);