|
9 | 9 | // We are temporarily importing the existing viewEngine from core so we can be sure we are
|
10 | 10 | // correctly implementing its interfaces for backwards compatibility.
|
11 | 11 | import {Injector} from '../di/injector';
|
12 |
| -import {Type} from '../interface/type'; |
13 | 12 | import {Sanitizer} from '../sanitization/sanitizer';
|
14 | 13 | import {assertDefined, assertIndexInRange} from '../util/assert';
|
15 | 14 |
|
16 |
| -import {assertComponentType} from './assert'; |
17 |
| -import {getComponentDef} from './definition'; |
18 | 15 | import {diPublicInInjector, getOrCreateNodeInjectorForNode} from './di';
|
19 | 16 | import {throwProviderNotFoundError} from './errors_di';
|
20 | 17 | import {registerPostOrderHooks} from './hooks';
|
21 |
| -import {addToViewTree, CLEAN_PROMISE, createLView, createTView, getOrCreateTComponentView, getOrCreateTNode, initTNodeFlags, instantiateRootComponent, invokeHostBindingsInCreationMode, locateHostElement, markAsComponentHost, refreshView, registerHostBindingOpCodes, renderView} from './instructions/shared'; |
22 |
| -import {ComponentDef, ComponentType, RenderFlags} from './interfaces/definition'; |
| 18 | +import {addToViewTree, CLEAN_PROMISE, createLView, getOrCreateTComponentView, getOrCreateTNode, initTNodeFlags, instantiateRootComponent, invokeHostBindingsInCreationMode, markAsComponentHost, registerHostBindingOpCodes} from './instructions/shared'; |
| 19 | +import {ComponentDef, RenderFlags} from './interfaces/definition'; |
23 | 20 | import {TElementNode, TNodeType} from './interfaces/node';
|
24 | 21 | import {PlayerHandler} from './interfaces/player';
|
25 | 22 | import {Renderer, RendererFactory} from './interfaces/renderer';
|
26 | 23 | import {RElement} from './interfaces/renderer_dom';
|
27 |
| -import {CONTEXT, HEADER_OFFSET, LView, LViewFlags, RootContext, RootContextFlags, TVIEW, TViewType} from './interfaces/view'; |
| 24 | +import {CONTEXT, HEADER_OFFSET, LView, LViewFlags, RootContext, RootContextFlags, TVIEW} from './interfaces/view'; |
28 | 25 | import {writeDirectClass, writeDirectStyle} from './node_manipulation';
|
29 |
| -import {enterView, getCurrentTNode, getLView, leaveView, setSelectedIndex} from './state'; |
| 26 | +import {getCurrentTNode, getLView, setSelectedIndex} from './state'; |
30 | 27 | import {computeStaticStyling} from './styling/static_styling';
|
31 | 28 | import {setUpAttributes} from './util/attrs_utils';
|
32 |
| -import {publishDefaultGlobalUtils} from './util/global_utils'; |
33 | 29 | import {defaultScheduler} from './util/misc_utils';
|
34 | 30 | import {getRootContext} from './util/view_traversal_utils';
|
35 | 31 |
|
@@ -94,70 +90,6 @@ export const NULL_INJECTOR: Injector = {
|
94 | 90 | }
|
95 | 91 | };
|
96 | 92 |
|
97 |
| -/** |
98 |
| - * Bootstraps a Component into an existing host element and returns an instance |
99 |
| - * of the component. |
100 |
| - * |
101 |
| - * Use this function to bootstrap a component into the DOM tree. Each invocation |
102 |
| - * of this function will create a separate tree of components, injectors and |
103 |
| - * change detection cycles and lifetimes. To dynamically insert a new component |
104 |
| - * into an existing tree such that it shares the same injection, change detection |
105 |
| - * and object lifetime, use {@link ViewContainer#createComponent}. |
106 |
| - * |
107 |
| - * @param componentType Component to bootstrap |
108 |
| - * @param options Optional parameters which control bootstrapping |
109 |
| - */ |
110 |
| -export function renderComponent<T>( |
111 |
| - componentType: ComponentType<T>| |
112 |
| - Type<T>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */ |
113 |
| - , |
114 |
| - opts: CreateComponentOptions = {}): T { |
115 |
| - ngDevMode && publishDefaultGlobalUtils(); |
116 |
| - ngDevMode && assertComponentType(componentType); |
117 |
| - |
118 |
| - const rendererFactory = opts.rendererFactory!; |
119 |
| - const sanitizer = opts.sanitizer || null; |
120 |
| - const componentDef = getComponentDef<T>(componentType)!; |
121 |
| - if (componentDef.type != componentType) (componentDef as {type: Type<any>}).type = componentType; |
122 |
| - |
123 |
| - // The first index of the first selector is the tag name. |
124 |
| - const componentTag = componentDef.selectors![0]![0] as string; |
125 |
| - const hostRenderer = rendererFactory.createRenderer(null, null); |
126 |
| - const hostRNode = |
127 |
| - locateHostElement(hostRenderer, opts.host || componentTag, componentDef.encapsulation); |
128 |
| - const rootFlags = componentDef.onPush ? LViewFlags.Dirty | LViewFlags.IsRoot : |
129 |
| - LViewFlags.CheckAlways | LViewFlags.IsRoot; |
130 |
| - const rootContext = createRootContext(opts.scheduler, opts.playerHandler); |
131 |
| - |
132 |
| - const renderer = rendererFactory.createRenderer(hostRNode, componentDef); |
133 |
| - const rootTView = createTView(TViewType.Root, null, null, 1, 0, null, null, null, null, null); |
134 |
| - const rootView: LView = createLView( |
135 |
| - null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, |
136 |
| - opts.injector || null, null); |
137 |
| - |
138 |
| - enterView(rootView); |
139 |
| - let component: T; |
140 |
| - |
141 |
| - try { |
142 |
| - if (rendererFactory.begin) rendererFactory.begin(); |
143 |
| - const componentView = createRootComponentView( |
144 |
| - hostRNode, componentDef, rootView, rendererFactory, renderer, sanitizer); |
145 |
| - component = createRootComponent( |
146 |
| - componentView, componentDef, rootView, rootContext, opts.hostFeatures || null); |
147 |
| - |
148 |
| - // create mode pass |
149 |
| - renderView(rootTView, rootView, null); |
150 |
| - // update mode pass |
151 |
| - refreshView(rootTView, rootView, null, null); |
152 |
| - |
153 |
| - } finally { |
154 |
| - leaveView(); |
155 |
| - if (rendererFactory.end) rendererFactory.end(); |
156 |
| - } |
157 |
| - |
158 |
| - return component; |
159 |
| -} |
160 |
| - |
161 | 93 | /**
|
162 | 94 | * Creates the root component view and the root component node.
|
163 | 95 | *
|
|
0 commit comments