From c1094cf46f292796ecd25f9096a7d91744498ed8 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Thu, 14 Feb 2019 16:28:31 +0100 Subject: [PATCH] refactor(ivy): remove duplicated getRootView function (#28732) PR Close #28732 --- packages/core/src/render3/component.ts | 4 ++-- packages/core/src/render3/discovery_utils.ts | 25 +------------------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/packages/core/src/render3/component.ts b/packages/core/src/render3/component.ts index 12f99a30c0..d586a2640e 100644 --- a/packages/core/src/render3/component.ts +++ b/packages/core/src/render3/component.ts @@ -18,12 +18,12 @@ import {getComponentDef} from './definition'; import {diPublicInInjector, getOrCreateNodeInjectorForNode} from './di'; import {publishDefaultGlobalUtils} from './global_utils'; import {registerPostOrderHooks, registerPreOrderHooks} from './hooks'; -import {CLEAN_PROMISE, addToViewTree, createLView, createNodeAtIndex, createTNode, createTView, getOrCreateTView, initNodeFlags, instantiateRootComponent, invokeHostBindingsInCreationMode, locateHostElement, queueComponentIndexForCheck, refreshDescendantViews} from './instructions'; +import {CLEAN_PROMISE, addToViewTree, createLView, createNodeAtIndex, createTView, getOrCreateTView, initNodeFlags, instantiateRootComponent, invokeHostBindingsInCreationMode, locateHostElement, queueComponentIndexForCheck, refreshDescendantViews} from './instructions'; import {ComponentDef, ComponentType, RenderFlags} from './interfaces/definition'; import {TElementNode, TNode, TNodeFlags, TNodeType} from './interfaces/node'; import {PlayerHandler} from './interfaces/player'; import {RElement, Renderer3, RendererFactory3, domRendererFactory3} from './interfaces/renderer'; -import {CONTEXT, FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, RootContext, RootContextFlags, TVIEW, T_HOST} from './interfaces/view'; +import {CONTEXT, FLAGS, HEADER_OFFSET, LView, LViewFlags, RootContext, RootContextFlags, TVIEW} from './interfaces/view'; import {enterView, getPreviousOrParentTNode, leaveView, resetComponentState, setCurrentDirectiveDef} from './state'; import {applyOnCreateInstructions, defaultScheduler, getRootView, readPatchedLView, renderStringify} from './util'; diff --git a/packages/core/src/render3/discovery_utils.ts b/packages/core/src/render3/discovery_utils.ts index 31701cd30c..a24f83be4b 100644 --- a/packages/core/src/render3/discovery_utils.ts +++ b/packages/core/src/render3/discovery_utils.ts @@ -8,14 +8,13 @@ import {Injector} from '../di/injector'; -import {assertDefined} from '../util/assert'; import {discoverLocalRefs, getComponentAtNodeIndex, getDirectivesAtNodeIndex, getLContext} from './context_discovery'; import {NodeInjector} from './di'; import {LContext} from './interfaces/context'; import {DirectiveDef} from './interfaces/definition'; import {TElementNode, TNode, TNodeProviderIndexes} from './interfaces/node'; import {CLEANUP, CONTEXT, FLAGS, HOST, LView, LViewFlags, PARENT, RootContext, TVIEW} from './interfaces/view'; -import {readElementValue, readPatchedLView, renderStringify} from './util'; +import {getRootView, readElementValue, renderStringify} from './util'; @@ -207,28 +206,6 @@ export function loadLContext(target: {}, throwOnNotFound: boolean = true): LCont return context; } -/** - * Retrieve the root view from any component by walking the parent `LView` until - * reaching the root `LView`. - * - * @param componentOrView any component or view - * - */ -export function getRootView(componentOrView: LView | {}): LView { - let lView: LView; - if (Array.isArray(componentOrView)) { - ngDevMode && assertDefined(componentOrView, 'lView'); - lView = componentOrView as LView; - } else { - ngDevMode && assertDefined(componentOrView, 'component'); - lView = readPatchedLView(componentOrView) !; - } - while (lView && !(lView[FLAGS] & LViewFlags.IsRoot)) { - lView = lView[PARENT] !; - } - return lView; -} - /** * Retrieve map of local references. *