2019-08-12 08:41:52 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
2019-08-12 06:31:15 -04:00
|
|
|
import {addToViewTree, createLContainer, createLView, createTNode, createTView, getOrCreateTNode, renderView} from '../../../src/render3/instructions/shared';
|
|
|
|
import {ComponentTemplate} from '../../../src/render3/interfaces/definition';
|
|
|
|
import {TNodeType, TViewNode} from '../../../src/render3/interfaces/node';
|
|
|
|
import {RComment} from '../../../src/render3/interfaces/renderer';
|
2019-08-27 08:44:16 -04:00
|
|
|
import {LView, LViewFlags, TView} from '../../../src/render3/interfaces/view';
|
2019-08-12 06:31:15 -04:00
|
|
|
import {insertView} from '../../../src/render3/node_manipulation';
|
|
|
|
|
|
|
|
import {NoopRenderer, NoopRendererFactory, WebWorkerRenderNode} from './noop_renderer';
|
|
|
|
|
2019-08-27 08:44:16 -04:00
|
|
|
export function createAndRenderLView(
|
|
|
|
parentLView: LView | null, tView: TView, hostTNode: TViewNode) {
|
|
|
|
const embeddedLView = createLView(
|
|
|
|
parentLView, tView, {}, LViewFlags.CheckAlways, null, hostTNode, new NoopRendererFactory(),
|
|
|
|
new NoopRenderer());
|
|
|
|
renderView(embeddedLView, tView, null);
|
|
|
|
}
|
|
|
|
|
2019-08-12 06:31:15 -04:00
|
|
|
export function setupRootViewWithEmbeddedViews(
|
2019-09-10 06:10:03 -04:00
|
|
|
templateFn: ComponentTemplate<any>| null, consts: number, vars: number, noOfViews: number,
|
|
|
|
embeddedViewContext: any = {}): LView {
|
2019-08-12 06:31:15 -04:00
|
|
|
// Create a root view with a container
|
|
|
|
const rootTView = createTView(-1, null, 1, 0, null, null, null, null);
|
|
|
|
const tContainerNode = getOrCreateTNode(rootTView, null, 0, TNodeType.Container, null, null);
|
|
|
|
const rootLView = createLView(
|
|
|
|
null, rootTView, {}, LViewFlags.CheckAlways | LViewFlags.IsRoot, null, null,
|
|
|
|
new NoopRendererFactory(), new NoopRenderer());
|
|
|
|
const mockRNode = new WebWorkerRenderNode();
|
|
|
|
const lContainer = createLContainer(
|
|
|
|
mockRNode as RComment, rootLView, mockRNode as RComment, tContainerNode, true);
|
|
|
|
addToViewTree(rootLView, lContainer);
|
|
|
|
|
|
|
|
|
|
|
|
// create test embedded views
|
|
|
|
const embeddedTView = createTView(-1, templateFn, consts, vars, null, null, null, null);
|
|
|
|
const viewTNode = createTNode(rootTView, null, TNodeType.View, -1, null, null) as TViewNode;
|
|
|
|
|
|
|
|
// create embedded views and add them to the container
|
|
|
|
for (let i = 0; i < noOfViews; i++) {
|
|
|
|
const embeddedLView = createLView(
|
2019-09-10 06:10:03 -04:00
|
|
|
rootLView, embeddedTView, embeddedViewContext, LViewFlags.CheckAlways, null, viewTNode,
|
2019-08-12 06:31:15 -04:00
|
|
|
new NoopRendererFactory(), new NoopRenderer());
|
|
|
|
renderView(embeddedLView, embeddedTView, null);
|
|
|
|
insertView(embeddedLView, lContainer, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// run in the creation mode to set flags etc.
|
|
|
|
renderView(rootLView, rootTView, null);
|
|
|
|
|
|
|
|
return rootLView;
|
|
|
|
}
|