diff --git a/goldens/size-tracking/integration-payloads.json b/goldens/size-tracking/integration-payloads.json index 21bca3acd8..12b8e34d10 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": 143350, + "main-es2015": 142812, "polyfills-es2015": 36657 } } @@ -21,7 +21,7 @@ "master": { "uncompressed": { "runtime-es2015": 1485, - "main-es2015": 149471, + "main-es2015": 148933, "polyfills-es2015": 36657 } } diff --git a/packages/core/src/render3/component_ref.ts b/packages/core/src/render3/component_ref.ts index 558c5f01f1..f4856ee57b 100644 --- a/packages/core/src/render3/component_ref.ts +++ b/packages/core/src/render3/component_ref.ts @@ -26,10 +26,11 @@ import {getComponentDef} from './definition'; import {NodeInjector} from './di'; import {assignTViewNodeToLView, createLView, createTView, elementCreate, locateHostElement, renderView} from './instructions/shared'; import {ComponentDef} from './interfaces/definition'; -import {TContainerNode, TElementContainerNode, TElementNode, TNode} from './interfaces/node'; +import {TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeType} from './interfaces/node'; import {domRendererFactory3, RendererFactory3, RNode} from './interfaces/renderer'; import {LView, LViewFlags, TVIEW, TViewType} from './interfaces/view'; import {MATH_ML_NAMESPACE, SVG_NAMESPACE} from './namespaces'; +import {assertNodeOfPossibleTypes} from './node_assert'; import {writeDirectClass} from './node_manipulation'; import {extractAttrsAndClassesFromSelector, stringifyCSSSelectorList} from './node_selector_matcher'; import {enterView, leaveView} from './state'; @@ -234,7 +235,8 @@ export class ComponentFactory extends viewEngine_ComponentFactory { if (!rootSelectorOrNode || isIsolated) { // The host element of the internal or isolated root view is attached to the component's host // view node. - componentRef.hostView._tViewNode!.child = tElementNode; + ngDevMode && assertNodeOfPossibleTypes(rootTView.node, TNodeType.View); + rootTView.node!.child = tElementNode; } return componentRef; } @@ -275,7 +277,7 @@ export class ComponentRef extends viewEngine_ComponentRef { super(); this.instance = instance; this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView); - this.hostView._tViewNode = assignTViewNodeToLView(_rootLView[TVIEW], null, -1, _rootLView); + assignTViewNodeToLView(_rootLView[TVIEW], null, -1, _rootLView); this.componentType = componentType; } diff --git a/packages/core/src/render3/instructions/shared.ts b/packages/core/src/render3/instructions/shared.ts index 6c4d15d91b..100a2cb92d 100644 --- a/packages/core/src/render3/instructions/shared.ts +++ b/packages/core/src/render3/instructions/shared.ts @@ -266,7 +266,7 @@ function createTNodeAtIndex( } export function assignTViewNodeToLView( - tView: TView, tParentNode: TNode|null, index: number, lView: LView): TViewNode { + tView: TView, tParentNode: TNode|null, index: number, lView: LView): void { // View nodes are not stored in data because they can be added / removed at runtime (which // would cause indices to change). Their TNodes are instead stored in tView.node. let tNode = tView.node; @@ -279,7 +279,7 @@ export function assignTViewNodeToLView( TNodeType.View, index, null, null) as TViewNode; } - return lView[T_HOST] = tNode as TViewNode; + lView[T_HOST] = tNode as TViewNode; } diff --git a/packages/core/src/render3/node_assert.ts b/packages/core/src/render3/node_assert.ts index 722c8f4fdc..9a3056dd7c 100644 --- a/packages/core/src/render3/node_assert.ts +++ b/packages/core/src/render3/node_assert.ts @@ -26,7 +26,7 @@ export function assertNodeType(tNode: TNode, type: TNodeType): asserts tNode is assertEqual(tNode.type, type, `should be a ${typeName(type)}`); } -export function assertNodeOfPossibleTypes(tNode: TNode, ...types: TNodeType[]): void { +export function assertNodeOfPossibleTypes(tNode: TNode|null, ...types: TNodeType[]): void { assertDefined(tNode, 'should be called with a TNode'); const found = types.some(type => tNode.type === type); assertEqual( diff --git a/packages/core/src/render3/view_engine_compatibility.ts b/packages/core/src/render3/view_engine_compatibility.ts index 8e9fa298f4..6f409f6241 100644 --- a/packages/core/src/render3/view_engine_compatibility.ts +++ b/packages/core/src/render3/view_engine_compatibility.ts @@ -119,9 +119,7 @@ export function createTemplateRef( renderView(embeddedTView, embeddedLView, context); - const viewRef = new ViewRef(embeddedLView); - viewRef._tViewNode = embeddedLView[T_HOST] as TViewNode; - return viewRef; + return new ViewRef(embeddedLView); } }; } diff --git a/packages/core/src/render3/view_ref.ts b/packages/core/src/render3/view_ref.ts index a8bf126d9d..da525c2d15 100644 --- a/packages/core/src/render3/view_ref.ts +++ b/packages/core/src/render3/view_ref.ts @@ -33,11 +33,6 @@ export class ViewRef implements viewEngine_EmbeddedViewRef, viewEngine_Int private _appRef: ApplicationRef|null = null; private _viewContainerRef: viewEngine_ViewContainerRef|null = null; - /** - * @internal - */ - public _tViewNode: TViewNode|null = null; - get rootNodes(): any[] { const lView = this._lView; if (lView[HOST] == null) { diff --git a/packages/core/src/util/assert.ts b/packages/core/src/util/assert.ts index c713d19910..ea0704fa98 100644 --- a/packages/core/src/util/assert.ts +++ b/packages/core/src/util/assert.ts @@ -86,7 +86,7 @@ export function assertNotDefined(actual: T, msg: string) { } } -export function assertDefined(actual: T, msg: string) { +export function assertDefined(actual: T|null|undefined, msg: string): asserts actual is T { if (actual == null) { throwError(msg, actual, null, '!='); }