From 4ff43e13246f1e976e65449955fb8689198e3d10 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Sun, 3 Nov 2019 12:06:39 +0100 Subject: [PATCH] refactor(ivy): remove the getHostNative utility function (#33554) We already store a reference to a native host of a component view so we can drop the getHostNative utility function (that was getting the same reference from another data structure). PR Close #33554 --- packages/core/src/render3/node_manipulation.ts | 17 +++-------------- .../cyclic_import/bundle.golden_symbols.json | 6 ------ .../hello_world/bundle.golden_symbols.json | 6 ------ .../bundling/todo/bundle.golden_symbols.json | 3 --- 4 files changed, 3 insertions(+), 29 deletions(-) diff --git a/packages/core/src/render3/node_manipulation.ts b/packages/core/src/render3/node_manipulation.ts index 5987eb4dd6..246b30b2c9 100644 --- a/packages/core/src/render3/node_manipulation.ts +++ b/packages/core/src/render3/node_manipulation.ts @@ -20,7 +20,7 @@ import {ProceduralRenderer3, RElement, RNode, RText, Renderer3, isProceduralRend import {isLContainer, isLView, isRootView} from './interfaces/type_checks'; import {CHILD_HEAD, CLEANUP, DECLARATION_LCONTAINER, FLAGS, HOST, HookData, LView, LViewFlags, NEXT, PARENT, QUERIES, RENDERER, TVIEW, T_HOST, unusedValueExportToPlacateAjd as unused5} from './interfaces/view'; import {assertNodeOfPossibleTypes, assertNodeType} from './node_assert'; -import {findComponentView, getLViewParent} from './util/view_traversal_utils'; +import {findComponentView} from './util/view_traversal_utils'; import {getNativeByTNode, getNativeByTNodeOrNull, unwrapRNode} from './util/view_utils'; const unusedValueToPlacateAjd = unused1 + unused2 + unused3 + unused4 + unused5; @@ -515,7 +515,8 @@ function getRenderParent(tNode: TNode, currentView: LView): RElement|null { } else { // We are inserting a root element of the component view into the component host element and // it should always be eager. - return getHostNative(currentView); + ngDevMode && assertNodeOfPossibleTypes(hostTNode, TNodeType.Element); + return currentView[HOST]; } } else { const isIcuCase = tNode && tNode.type === TNodeType.IcuContainer; @@ -547,18 +548,6 @@ function getRenderParent(tNode: TNode, currentView: LView): RElement|null { } } -/** - * Gets the native host element for a given view. Will return null if the current view does not have - * a host element. - */ -function getHostNative(currentView: LView): RElement|null { - ngDevMode && assertLView(currentView); - const hostTNode = currentView[T_HOST]; - return hostTNode && hostTNode.type === TNodeType.Element ? - (getNativeByTNode(hostTNode, getLViewParent(currentView) !) as RElement) : - null; -} - /** * Inserts a native node before another native node for a given parent using {@link Renderer3}. * This is a utility function that can be used when native nodes were determined - it abstracts an 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 186fbeae27..910d2e833a 100644 --- a/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json +++ b/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json @@ -311,9 +311,6 @@ { "name": "getFactoryDef" }, - { - "name": "getHostNative" - }, { "name": "getInitialStylingValue" }, @@ -329,9 +326,6 @@ { "name": "getLView" }, - { - "name": "getLViewParent" - }, { "name": "getMapProp" }, 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 46ff0fb4bf..826f028b3d 100644 --- a/packages/core/test/bundling/hello_world/bundle.golden_symbols.json +++ b/packages/core/test/bundling/hello_world/bundle.golden_symbols.json @@ -245,9 +245,6 @@ { "name": "getFactoryDef" }, - { - "name": "getHostNative" - }, { "name": "getInjectorIndex" }, @@ -260,9 +257,6 @@ { "name": "getLView" }, - { - "name": "getLViewParent" - }, { "name": "getNativeAnchorNode" }, diff --git a/packages/core/test/bundling/todo/bundle.golden_symbols.json b/packages/core/test/bundling/todo/bundle.golden_symbols.json index c125813312..ce81644958 100644 --- a/packages/core/test/bundling/todo/bundle.golden_symbols.json +++ b/packages/core/test/bundling/todo/bundle.golden_symbols.json @@ -671,9 +671,6 @@ { "name": "getGuardMask" }, - { - "name": "getHostNative" - }, { "name": "getInitialStylingValue" },