feat(core): view engine - support content projection (#14209)
Part of #14013 PR Close #14209
This commit is contained in:
parent
86b2b2504f
commit
0a29574d98
|
@ -13,8 +13,8 @@ import {BindingDef, BindingType, DebugContext, DisposableFn, ElementData, Elemen
|
||||||
import {checkAndUpdateBinding, entryAction, setBindingDebugInfo, setCurrentNode, sliceErrorStack} from './util';
|
import {checkAndUpdateBinding, entryAction, setBindingDebugInfo, setCurrentNode, sliceErrorStack} from './util';
|
||||||
|
|
||||||
export function anchorDef(
|
export function anchorDef(
|
||||||
flags: NodeFlags, matchedQueries: [string, QueryValueType][], childCount: number,
|
flags: NodeFlags, matchedQueries: [string, QueryValueType][], ngContentIndex: number,
|
||||||
template?: ViewDefinition): NodeDef {
|
childCount: number, template?: ViewDefinition): NodeDef {
|
||||||
const matchedQueryDefs: {[queryId: string]: QueryValueType} = {};
|
const matchedQueryDefs: {[queryId: string]: QueryValueType} = {};
|
||||||
if (matchedQueries) {
|
if (matchedQueries) {
|
||||||
matchedQueries.forEach(([queryId, valueType]) => { matchedQueryDefs[queryId] = valueType; });
|
matchedQueries.forEach(([queryId, valueType]) => { matchedQueryDefs[queryId] = valueType; });
|
||||||
|
@ -33,7 +33,7 @@ export function anchorDef(
|
||||||
disposableIndex: undefined,
|
disposableIndex: undefined,
|
||||||
// regular values
|
// regular values
|
||||||
flags,
|
flags,
|
||||||
matchedQueries: matchedQueryDefs, childCount,
|
matchedQueries: matchedQueryDefs, ngContentIndex, childCount,
|
||||||
bindings: [],
|
bindings: [],
|
||||||
disposableCount: 0,
|
disposableCount: 0,
|
||||||
element: {
|
element: {
|
||||||
|
@ -41,18 +41,19 @@ export function anchorDef(
|
||||||
attrs: undefined,
|
attrs: undefined,
|
||||||
outputs: [], template,
|
outputs: [], template,
|
||||||
// will bet set by the view definition
|
// will bet set by the view definition
|
||||||
providerIndices: undefined, source
|
providerIndices: undefined, source,
|
||||||
},
|
},
|
||||||
provider: undefined,
|
provider: undefined,
|
||||||
text: undefined,
|
text: undefined,
|
||||||
pureExpression: undefined,
|
pureExpression: undefined,
|
||||||
query: undefined,
|
query: undefined,
|
||||||
|
ngContent: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function elementDef(
|
export function elementDef(
|
||||||
flags: NodeFlags, matchedQueries: [string, QueryValueType][], childCount: number, name: string,
|
flags: NodeFlags, matchedQueries: [string, QueryValueType][], ngContentIndex: number,
|
||||||
fixedAttrs: {[name: string]: string} = {},
|
childCount: number, name: string, fixedAttrs: {[name: string]: string} = {},
|
||||||
bindings?:
|
bindings?:
|
||||||
([BindingType.ElementClass, string] | [BindingType.ElementStyle, string, string] |
|
([BindingType.ElementClass, string] | [BindingType.ElementStyle, string, string] |
|
||||||
[BindingType.ElementAttribute | BindingType.ElementProperty, string, SecurityContext])[],
|
[BindingType.ElementAttribute | BindingType.ElementProperty, string, SecurityContext])[],
|
||||||
|
@ -108,7 +109,7 @@ export function elementDef(
|
||||||
disposableIndex: undefined,
|
disposableIndex: undefined,
|
||||||
// regular values
|
// regular values
|
||||||
flags,
|
flags,
|
||||||
matchedQueries: matchedQueryDefs, childCount,
|
matchedQueries: matchedQueryDefs, ngContentIndex, childCount,
|
||||||
bindings: bindingDefs,
|
bindings: bindingDefs,
|
||||||
disposableCount: outputDefs.length,
|
disposableCount: outputDefs.length,
|
||||||
element: {
|
element: {
|
||||||
|
@ -117,12 +118,13 @@ export function elementDef(
|
||||||
outputs: outputDefs,
|
outputs: outputDefs,
|
||||||
template: undefined,
|
template: undefined,
|
||||||
// will bet set by the view definition
|
// will bet set by the view definition
|
||||||
providerIndices: undefined, source
|
providerIndices: undefined, source,
|
||||||
},
|
},
|
||||||
provider: undefined,
|
provider: undefined,
|
||||||
text: undefined,
|
text: undefined,
|
||||||
pureExpression: undefined,
|
pureExpression: undefined,
|
||||||
query: undefined,
|
query: undefined,
|
||||||
|
ngContent: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {anchorDef, elementDef} from './element';
|
export {anchorDef, elementDef} from './element';
|
||||||
|
export {ngContentDef} from './ng_content';
|
||||||
export {providerDef} from './provider';
|
export {providerDef} from './provider';
|
||||||
export {pureArrayDef, pureObjectDef, purePipeDef} from './pure_expression';
|
export {pureArrayDef, pureObjectDef, purePipeDef} from './pure_expression';
|
||||||
export {queryDef} from './query';
|
export {queryDef} from './query';
|
||||||
export {textDef} from './text';
|
export {textDef} from './text';
|
||||||
export {setCurrentNode} from './util';
|
export {rootRenderNodes, setCurrentNode} from './util';
|
||||||
export {checkAndUpdateView, checkNoChangesView, checkNodeDynamic, checkNodeInline, createEmbeddedView, createRootView, destroyView, viewDef} from './view';
|
export {checkAndUpdateView, checkNoChangesView, checkNodeDynamic, checkNodeInline, createEmbeddedView, createRootView, destroyView, viewDef} from './view';
|
||||||
export {attachEmbeddedView, detachEmbeddedView, rootRenderNodes} from './view_attach';
|
export {attachEmbeddedView, detachEmbeddedView} from './view_attach';
|
||||||
|
|
||||||
export * from './types';
|
export * from './types';
|
||||||
export {DefaultServices} from './services';
|
export {DefaultServices} from './services';
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {NodeDef, NodeType, ViewData, asElementData} from './types';
|
||||||
|
import {RenderNodeAction, visitProjectedRenderNodes} from './util';
|
||||||
|
|
||||||
|
export function ngContentDef(ngContentIndex: number, index: number): NodeDef {
|
||||||
|
return {
|
||||||
|
type: NodeType.NgContent,
|
||||||
|
// will bet set by the view definition
|
||||||
|
index: undefined,
|
||||||
|
reverseChildIndex: undefined,
|
||||||
|
parent: undefined,
|
||||||
|
childFlags: undefined,
|
||||||
|
childMatchedQueries: undefined,
|
||||||
|
bindingIndex: undefined,
|
||||||
|
disposableIndex: undefined,
|
||||||
|
// regular values
|
||||||
|
flags: 0,
|
||||||
|
matchedQueries: {}, ngContentIndex,
|
||||||
|
childCount: 0,
|
||||||
|
bindings: [],
|
||||||
|
disposableCount: 0,
|
||||||
|
element: undefined,
|
||||||
|
provider: undefined,
|
||||||
|
text: undefined,
|
||||||
|
pureExpression: undefined,
|
||||||
|
query: undefined,
|
||||||
|
ngContent: {index}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function appendNgContent(view: ViewData, renderHost: any, def: NodeDef) {
|
||||||
|
if (def.ngContentIndex != null) {
|
||||||
|
// Do nothing if we are reprojected!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const parentEl = def.parent != null ? asElementData(view, def.parent).renderElement : renderHost;
|
||||||
|
if (!parentEl) {
|
||||||
|
// Nothing to do if there is no parent element.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ngContentIndex = def.ngContent.index;
|
||||||
|
if (view.renderer) {
|
||||||
|
const projectedNodes: any[] = [];
|
||||||
|
visitProjectedRenderNodes(
|
||||||
|
view, ngContentIndex, RenderNodeAction.Collect, undefined, undefined, projectedNodes);
|
||||||
|
view.renderer.projectNodes(parentEl, projectedNodes);
|
||||||
|
} else {
|
||||||
|
visitProjectedRenderNodes(
|
||||||
|
view, ngContentIndex, RenderNodeAction.AppendChild, parentEl, undefined, undefined);
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,7 +80,8 @@ export function providerDef(
|
||||||
disposableIndex: undefined,
|
disposableIndex: undefined,
|
||||||
// regular values
|
// regular values
|
||||||
flags,
|
flags,
|
||||||
matchedQueries: matchedQueryDefs, childCount, bindings,
|
matchedQueries: matchedQueryDefs,
|
||||||
|
ngContentIndex: undefined, childCount, bindings,
|
||||||
disposableCount: outputDefs.length,
|
disposableCount: outputDefs.length,
|
||||||
element: undefined,
|
element: undefined,
|
||||||
provider: {
|
provider: {
|
||||||
|
@ -91,7 +92,8 @@ export function providerDef(
|
||||||
},
|
},
|
||||||
text: undefined,
|
text: undefined,
|
||||||
pureExpression: undefined,
|
pureExpression: undefined,
|
||||||
query: undefined
|
query: undefined,
|
||||||
|
ngContent: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ function _pureExpressionDef(
|
||||||
// regular values
|
// regular values
|
||||||
flags: 0,
|
flags: 0,
|
||||||
matchedQueries: {},
|
matchedQueries: {},
|
||||||
|
ngContentIndex: undefined,
|
||||||
childCount: 0, bindings,
|
childCount: 0, bindings,
|
||||||
disposableCount: 0,
|
disposableCount: 0,
|
||||||
element: undefined,
|
element: undefined,
|
||||||
|
@ -57,6 +58,7 @@ function _pureExpressionDef(
|
||||||
text: undefined,
|
text: undefined,
|
||||||
pureExpression: {type, pipeDep},
|
pureExpression: {type, pipeDep},
|
||||||
query: undefined,
|
query: undefined,
|
||||||
|
ngContent: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ export function queryDef(
|
||||||
disposableIndex: undefined,
|
disposableIndex: undefined,
|
||||||
// regular values
|
// regular values
|
||||||
flags,
|
flags,
|
||||||
|
ngContentIndex: undefined,
|
||||||
matchedQueries: {},
|
matchedQueries: {},
|
||||||
childCount: 0,
|
childCount: 0,
|
||||||
bindings: [],
|
bindings: [],
|
||||||
|
@ -42,7 +43,8 @@ export function queryDef(
|
||||||
provider: undefined,
|
provider: undefined,
|
||||||
text: undefined,
|
text: undefined,
|
||||||
pureExpression: undefined,
|
pureExpression: undefined,
|
||||||
query: {id, bindings: bindingDefs}
|
query: {id, bindings: bindingDefs},
|
||||||
|
ngContent: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ import {Sanitizer, SecurityContext} from '../security';
|
||||||
import {createInjector} from './provider';
|
import {createInjector} from './provider';
|
||||||
import {getQueryValue} from './query';
|
import {getQueryValue} from './query';
|
||||||
import {DebugContext, ElementData, NodeData, NodeDef, NodeType, Services, ViewData, ViewDefinition, asElementData} from './types';
|
import {DebugContext, ElementData, NodeData, NodeDef, NodeType, Services, ViewData, ViewDefinition, asElementData} from './types';
|
||||||
import {isComponentView, renderNode} from './util';
|
import {isComponentView, renderNode, rootRenderNodes} from './util';
|
||||||
import {checkAndUpdateView, checkNoChangesView, createEmbeddedView, destroyView} from './view';
|
import {checkAndUpdateView, checkNoChangesView, createEmbeddedView, destroyView} from './view';
|
||||||
import {attachEmbeddedView, detachEmbeddedView, rootRenderNodes} from './view_attach';
|
import {attachEmbeddedView, detachEmbeddedView} from './view_attach';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DefaultServices implements Services {
|
export class DefaultServices implements Services {
|
||||||
|
@ -140,6 +140,10 @@ class DebugContext_ implements DebugContext {
|
||||||
private nodeDef: NodeDef;
|
private nodeDef: NodeDef;
|
||||||
private elDef: NodeDef;
|
private elDef: NodeDef;
|
||||||
constructor(public view: ViewData, public nodeIndex: number) {
|
constructor(public view: ViewData, public nodeIndex: number) {
|
||||||
|
if (nodeIndex == null) {
|
||||||
|
this.nodeIndex = nodeIndex = view.parentIndex;
|
||||||
|
this.view = view = view.parent;
|
||||||
|
}
|
||||||
this.nodeDef = view.def.nodes[nodeIndex];
|
this.nodeDef = view.def.nodes[nodeIndex];
|
||||||
this.elDef = findElementDef(view, nodeIndex);
|
this.elDef = findElementDef(view, nodeIndex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {looseIdentical} from '../facade/lang';
|
||||||
import {BindingDef, BindingType, DebugContext, NodeData, NodeDef, NodeFlags, NodeType, Services, TextData, ViewData, ViewFlags, asElementData, asTextData} from './types';
|
import {BindingDef, BindingType, DebugContext, NodeData, NodeDef, NodeFlags, NodeType, Services, TextData, ViewData, ViewFlags, asElementData, asTextData} from './types';
|
||||||
import {checkAndUpdateBinding, sliceErrorStack} from './util';
|
import {checkAndUpdateBinding, sliceErrorStack} from './util';
|
||||||
|
|
||||||
export function textDef(constants: string[]): NodeDef {
|
export function textDef(ngContentIndex: number, constants: string[]): NodeDef {
|
||||||
// skip the call to sliceErrorStack itself + the call to this function.
|
// skip the call to sliceErrorStack itself + the call to this function.
|
||||||
const source = isDevMode() ? sliceErrorStack(2, 3) : '';
|
const source = isDevMode() ? sliceErrorStack(2, 3) : '';
|
||||||
const bindings: BindingDef[] = new Array(constants.length - 1);
|
const bindings: BindingDef[] = new Array(constants.length - 1);
|
||||||
|
@ -37,7 +37,7 @@ export function textDef(constants: string[]): NodeDef {
|
||||||
disposableIndex: undefined,
|
disposableIndex: undefined,
|
||||||
// regular values
|
// regular values
|
||||||
flags: 0,
|
flags: 0,
|
||||||
matchedQueries: {},
|
matchedQueries: {}, ngContentIndex,
|
||||||
childCount: 0, bindings,
|
childCount: 0, bindings,
|
||||||
disposableCount: 0,
|
disposableCount: 0,
|
||||||
element: undefined,
|
element: undefined,
|
||||||
|
@ -45,6 +45,7 @@ export function textDef(constants: string[]): NodeDef {
|
||||||
text: {prefix: constants[0], source},
|
text: {prefix: constants[0], source},
|
||||||
pureExpression: undefined,
|
pureExpression: undefined,
|
||||||
query: undefined,
|
query: undefined,
|
||||||
|
ngContent: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,14 @@ export interface ViewDefinition {
|
||||||
handleEvent: ViewHandleEventFn;
|
handleEvent: ViewHandleEventFn;
|
||||||
/**
|
/**
|
||||||
* Order: Depth first.
|
* Order: Depth first.
|
||||||
* Especially providers are before elements / anchros.
|
* Especially providers are before elements / anchors.
|
||||||
*/
|
*/
|
||||||
nodes: NodeDef[];
|
nodes: NodeDef[];
|
||||||
/** aggregated NodeFlags for all nodes **/
|
/** aggregated NodeFlags for all nodes **/
|
||||||
nodeFlags: NodeFlags;
|
nodeFlags: NodeFlags;
|
||||||
/**
|
/**
|
||||||
* Order: parents before children, but children in reverse order.
|
* Order: parents before children, but children in reverse order.
|
||||||
* Especially providers are after elements / anchros.
|
* Especially providers are after elements / anchors.
|
||||||
*/
|
*/
|
||||||
reverseChildNodes: NodeDef[];
|
reverseChildNodes: NodeDef[];
|
||||||
lastRootNode: NodeDef;
|
lastRootNode: NodeDef;
|
||||||
|
@ -71,6 +71,8 @@ export interface NodeDef {
|
||||||
reverseChildIndex: number;
|
reverseChildIndex: number;
|
||||||
flags: NodeFlags;
|
flags: NodeFlags;
|
||||||
parent: number;
|
parent: number;
|
||||||
|
/** this is checked against NgContentDef.index to find matched nodes */
|
||||||
|
ngContentIndex: number;
|
||||||
/** number of transitive children */
|
/** number of transitive children */
|
||||||
childCount: number;
|
childCount: number;
|
||||||
/** aggregated NodeFlags for all children **/
|
/** aggregated NodeFlags for all children **/
|
||||||
|
@ -94,6 +96,7 @@ export interface NodeDef {
|
||||||
text: TextDef;
|
text: TextDef;
|
||||||
pureExpression: PureExpressionDef;
|
pureExpression: PureExpressionDef;
|
||||||
query: QueryDef;
|
query: QueryDef;
|
||||||
|
ngContent: NgContentDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NodeType {
|
export enum NodeType {
|
||||||
|
@ -102,6 +105,7 @@ export enum NodeType {
|
||||||
Provider,
|
Provider,
|
||||||
PureExpression,
|
PureExpression,
|
||||||
Query,
|
Query,
|
||||||
|
NgContent
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -229,6 +233,16 @@ export enum QueryBindingType {
|
||||||
All
|
All
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface NgContentDef {
|
||||||
|
/**
|
||||||
|
* this index is checked against NodeDef.ngContentIndex to find the nodes
|
||||||
|
* that are matched by this ng-content.
|
||||||
|
* Note that a NodeDef with an ng-content can be reprojected, i.e.
|
||||||
|
* have a ngContentIndex on its own.
|
||||||
|
*/
|
||||||
|
index: number;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
// Data
|
// Data
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
|
|
|
@ -170,3 +170,82 @@ function callWithTryCatch(fn: (a: any) => any, arg: any): any {
|
||||||
throw viewWrappedError(e, debugContext);
|
throw viewWrappedError(e, debugContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function rootRenderNodes(view: ViewData): any[] {
|
||||||
|
const renderNodes: any[] = [];
|
||||||
|
visitRootRenderNodes(view, RenderNodeAction.Collect, undefined, undefined, renderNodes);
|
||||||
|
return renderNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum RenderNodeAction {
|
||||||
|
Collect,
|
||||||
|
AppendChild,
|
||||||
|
InsertBefore,
|
||||||
|
RemoveChild
|
||||||
|
}
|
||||||
|
|
||||||
|
export function visitRootRenderNodes(
|
||||||
|
view: ViewData, action: RenderNodeAction, parentNode: any, nextSibling: any, target: any[]) {
|
||||||
|
const len = view.def.nodes.length;
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
const nodeDef = view.def.nodes[i];
|
||||||
|
visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target);
|
||||||
|
// jump to next sibling
|
||||||
|
i += nodeDef.childCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function visitProjectedRenderNodes(
|
||||||
|
view: ViewData, ngContentIndex: number, action: RenderNodeAction, parentNode: any,
|
||||||
|
nextSibling: any, target: any[]) {
|
||||||
|
let compView = view;
|
||||||
|
while (!isComponentView(compView)) {
|
||||||
|
compView = compView.parent;
|
||||||
|
}
|
||||||
|
const hostView = compView.parent;
|
||||||
|
const hostElDef = hostView.def.nodes[compView.parentIndex];
|
||||||
|
const startIndex = hostElDef.index + 1;
|
||||||
|
const endIndex = hostElDef.index + hostElDef.childCount;
|
||||||
|
for (let i = startIndex; i <= endIndex; i++) {
|
||||||
|
const nodeDef = hostView.def.nodes[i];
|
||||||
|
if (nodeDef.ngContentIndex === ngContentIndex) {
|
||||||
|
visitRenderNode(hostView, nodeDef, action, parentNode, nextSibling, target);
|
||||||
|
}
|
||||||
|
// jump to next sibling
|
||||||
|
i += nodeDef.childCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function visitRenderNode(
|
||||||
|
view: ViewData, nodeDef: NodeDef, action: RenderNodeAction, parentNode: any, nextSibling: any,
|
||||||
|
target: any[]) {
|
||||||
|
if (nodeDef.type === NodeType.NgContent) {
|
||||||
|
visitProjectedRenderNodes(
|
||||||
|
view, nodeDef.ngContent.index, action, parentNode, nextSibling, target);
|
||||||
|
} else {
|
||||||
|
const rn = renderNode(view, nodeDef);
|
||||||
|
switch (action) {
|
||||||
|
case RenderNodeAction.AppendChild:
|
||||||
|
parentNode.appendChild(rn);
|
||||||
|
break;
|
||||||
|
case RenderNodeAction.InsertBefore:
|
||||||
|
parentNode.insertBefore(rn, nextSibling);
|
||||||
|
break;
|
||||||
|
case RenderNodeAction.RemoveChild:
|
||||||
|
parentNode.removeChild(rn);
|
||||||
|
break;
|
||||||
|
case RenderNodeAction.Collect:
|
||||||
|
target.push(rn);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nodeDef.flags & NodeFlags.HasEmbeddedViews) {
|
||||||
|
const embeddedViews = asElementData(view, nodeDef.index).embeddedViews;
|
||||||
|
if (embeddedViews) {
|
||||||
|
for (let k = 0; k < embeddedViews.length; k++) {
|
||||||
|
visitRootRenderNodes(embeddedViews[k], action, parentNode, nextSibling, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {RenderComponentType, Renderer} from '../render/api';
|
||||||
|
|
||||||
import {checkAndUpdateElementDynamic, checkAndUpdateElementInline, createElement} from './element';
|
import {checkAndUpdateElementDynamic, checkAndUpdateElementInline, createElement} from './element';
|
||||||
import {expressionChangedAfterItHasBeenCheckedError} from './errors';
|
import {expressionChangedAfterItHasBeenCheckedError} from './errors';
|
||||||
|
import {appendNgContent} from './ng_content';
|
||||||
import {callLifecycleHooksChildrenFirst, checkAndUpdateProviderDynamic, checkAndUpdateProviderInline, createProvider} from './provider';
|
import {callLifecycleHooksChildrenFirst, checkAndUpdateProviderDynamic, checkAndUpdateProviderInline, createProvider} from './provider';
|
||||||
import {checkAndUpdatePureExpressionDynamic, checkAndUpdatePureExpressionInline, createPureExpression} from './pure_expression';
|
import {checkAndUpdatePureExpressionDynamic, checkAndUpdatePureExpressionInline, createPureExpression} from './pure_expression';
|
||||||
import {checkAndUpdateQuery, createQuery, queryDef} from './query';
|
import {checkAndUpdateQuery, createQuery, queryDef} from './query';
|
||||||
|
@ -316,6 +317,11 @@ function _createViewNodes(view: ViewData) {
|
||||||
case NodeType.Query:
|
case NodeType.Query:
|
||||||
nodeData = createQuery();
|
nodeData = createQuery();
|
||||||
break;
|
break;
|
||||||
|
case NodeType.NgContent:
|
||||||
|
appendNgContent(view, renderHost, nodeDef);
|
||||||
|
// no runtime data needed for NgContent...
|
||||||
|
nodeData = undefined;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
nodes[i] = nodeData;
|
nodes[i] = nodeData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {dirtyParentQuery} from './query';
|
import {dirtyParentQuery} from './query';
|
||||||
import {ElementData, NodeData, NodeFlags, NodeType, ViewData, asElementData, asProviderData, asTextData} from './types';
|
import {ElementData, NodeData, NodeDef, NodeFlags, NodeType, ViewData, asElementData, asProviderData, asTextData} from './types';
|
||||||
import {declaredViewContainer, renderNode} from './util';
|
import {RenderNodeAction, declaredViewContainer, isComponentView, renderNode, rootRenderNodes, visitProjectedRenderNodes, visitRootRenderNodes} from './util';
|
||||||
|
|
||||||
export function attachEmbeddedView(elementData: ElementData, viewIndex: number, view: ViewData) {
|
export function attachEmbeddedView(elementData: ElementData, viewIndex: number, view: ViewData) {
|
||||||
let embeddedViews = elementData.embeddedViews;
|
let embeddedViews = elementData.embeddedViews;
|
||||||
|
@ -39,8 +39,8 @@ export function attachEmbeddedView(elementData: ElementData, viewIndex: number,
|
||||||
const parentNode = prevRenderNode.parentNode;
|
const parentNode = prevRenderNode.parentNode;
|
||||||
const nextSibling = prevRenderNode.nextSibling;
|
const nextSibling = prevRenderNode.nextSibling;
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
const action = nextSibling ? DirectDomAction.InsertBefore : DirectDomAction.AppendChild;
|
const action = nextSibling ? RenderNodeAction.InsertBefore : RenderNodeAction.AppendChild;
|
||||||
directDomAttachDetachSiblingRenderNodes(view, 0, action, parentNode, nextSibling);
|
visitRootRenderNodes(view, action, parentNode, nextSibling, undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,7 @@ export function detachEmbeddedView(elementData: ElementData, viewIndex: number):
|
||||||
} else {
|
} else {
|
||||||
const parentNode = elementData.renderElement.parentNode;
|
const parentNode = elementData.renderElement.parentNode;
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
directDomAttachDetachSiblingRenderNodes(
|
visitRootRenderNodes(view, RenderNodeAction.RemoveChild, parentNode, null, undefined);
|
||||||
view, 0, DirectDomAction.RemoveChild, parentNode, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
|
@ -93,65 +92,3 @@ function removeFromArray(arr: any[], index: number) {
|
||||||
arr.splice(index, 1);
|
arr.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rootRenderNodes(view: ViewData): any[] {
|
|
||||||
const renderNodes: any[] = [];
|
|
||||||
collectSiblingRenderNodes(view, 0, renderNodes);
|
|
||||||
return renderNodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
function collectSiblingRenderNodes(view: ViewData, startIndex: number, target: any[]) {
|
|
||||||
const nodeCount = view.def.nodes.length;
|
|
||||||
for (let i = startIndex; i < nodeCount; i++) {
|
|
||||||
const nodeDef = view.def.nodes[i];
|
|
||||||
target.push(renderNode(view, nodeDef));
|
|
||||||
if (nodeDef.flags & NodeFlags.HasEmbeddedViews) {
|
|
||||||
const embeddedViews = asElementData(view, i).embeddedViews;
|
|
||||||
if (embeddedViews) {
|
|
||||||
for (let k = 0; k < embeddedViews.length; k++) {
|
|
||||||
collectSiblingRenderNodes(embeddedViews[k], 0, target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// jump to next sibling
|
|
||||||
i += nodeDef.childCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum DirectDomAction {
|
|
||||||
AppendChild,
|
|
||||||
InsertBefore,
|
|
||||||
RemoveChild
|
|
||||||
}
|
|
||||||
|
|
||||||
function directDomAttachDetachSiblingRenderNodes(
|
|
||||||
view: ViewData, startIndex: number, action: DirectDomAction, parentNode: any,
|
|
||||||
nextSibling: any) {
|
|
||||||
const nodeCount = view.def.nodes.length;
|
|
||||||
for (let i = startIndex; i < nodeCount; i++) {
|
|
||||||
const nodeDef = view.def.nodes[i];
|
|
||||||
const rn = renderNode(view, nodeDef);
|
|
||||||
switch (action) {
|
|
||||||
case DirectDomAction.AppendChild:
|
|
||||||
parentNode.appendChild(rn);
|
|
||||||
break;
|
|
||||||
case DirectDomAction.InsertBefore:
|
|
||||||
parentNode.insertBefore(rn, nextSibling);
|
|
||||||
break;
|
|
||||||
case DirectDomAction.RemoveChild:
|
|
||||||
parentNode.removeChild(rn);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (nodeDef.flags & NodeFlags.HasEmbeddedViews) {
|
|
||||||
const embeddedViews = asElementData(view, i).embeddedViews;
|
|
||||||
if (embeddedViews) {
|
|
||||||
for (let k = 0; k < embeddedViews.length; k++) {
|
|
||||||
directDomAttachDetachSiblingRenderNodes(
|
|
||||||
embeddedViews[k], 0, action, parentNode, nextSibling);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// jump to next sibling
|
|
||||||
i += nodeDef.childCount;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -48,22 +48,24 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
describe('create', () => {
|
describe('create', () => {
|
||||||
it('should create anchor nodes without parents', () => {
|
it('should create anchor nodes without parents', () => {
|
||||||
const rootNodes =
|
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||||
createAndGetRootNodes(compViewDef([anchorDef(NodeFlags.None, null, 0)])).rootNodes;
|
anchorDef(NodeFlags.None, null, null, 0)
|
||||||
|
])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(1);
|
expect(rootNodes.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create views with multiple root anchor nodes', () => {
|
it('should create views with multiple root anchor nodes', () => {
|
||||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
const rootNodes =
|
||||||
anchorDef(NodeFlags.None, null, 0), anchorDef(NodeFlags.None, null, 0)
|
createAndGetRootNodes(compViewDef([
|
||||||
])).rootNodes;
|
anchorDef(NodeFlags.None, null, null, 0), anchorDef(NodeFlags.None, null, null, 0)
|
||||||
|
])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(2);
|
expect(rootNodes.length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create anchor nodes with parents', () => {
|
it('should create anchor nodes with parents', () => {
|
||||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
anchorDef(NodeFlags.None, null, 0),
|
anchorDef(NodeFlags.None, null, null, 0),
|
||||||
])).rootNodes;
|
])).rootNodes;
|
||||||
expect(getDOM().childNodes(rootNodes[0]).length).toBe(1);
|
expect(getDOM().childNodes(rootNodes[0]).length).toBe(1);
|
||||||
});
|
});
|
||||||
|
@ -71,8 +73,8 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
if (!config.directDom) {
|
if (!config.directDom) {
|
||||||
it('should add debug information to the renderer', () => {
|
it('should add debug information to the renderer', () => {
|
||||||
const someContext = new Object();
|
const someContext = new Object();
|
||||||
const {view, rootNodes} =
|
const {view, rootNodes} = createAndGetRootNodes(
|
||||||
createAndGetRootNodes(compViewDef([anchorDef(NodeFlags.None, null, 0)]), someContext);
|
compViewDef([anchorDef(NodeFlags.None, null, null, 0)]), someContext);
|
||||||
expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asElementData(view, 0).renderElement);
|
expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asElementData(view, 0).renderElement);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,11 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, AComp, [], null, null,
|
NodeFlags.None, null, 0, AComp, [], null, null,
|
||||||
() => compViewDef([
|
() => compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 0, 'span'),
|
elementDef(NodeFlags.None, null, null, 0, 'span'),
|
||||||
])),
|
])),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -82,10 +82,10 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(
|
const {view, rootNodes} = createAndGetRootNodes(
|
||||||
compViewDef([
|
compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
providerDef(NodeFlags.None, null, 0, AComp, [], null, null, () => compViewDef(
|
providerDef(NodeFlags.None, null, 0, AComp, [], null, null, () => compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 0, 'span', null, [[BindingType.ElementAttribute, 'a', SecurityContext.NONE]]),
|
elementDef(NodeFlags.None, null, null, 0, 'span', null, [[BindingType.ElementAttribute, 'a', SecurityContext.NONE]]),
|
||||||
], update
|
], update
|
||||||
)),
|
)),
|
||||||
], jasmine.createSpy('parentUpdater')));
|
], jasmine.createSpy('parentUpdater')));
|
||||||
|
@ -116,11 +116,11 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, AComp, [], null, null,
|
NodeFlags.None, null, 0, AComp, [], null, null,
|
||||||
() => compViewDef([
|
() => compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.OnDestroy, null, 0, ChildProvider, [])
|
providerDef(NodeFlags.OnDestroy, null, 0, ChildProvider, [])
|
||||||
])),
|
])),
|
||||||
]));
|
]));
|
||||||
|
|
|
@ -49,7 +49,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
describe('create', () => {
|
describe('create', () => {
|
||||||
it('should create elements without parents', () => {
|
it('should create elements without parents', () => {
|
||||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 0, 'span')
|
elementDef(NodeFlags.None, null, null, 0, 'span')
|
||||||
])).rootNodes;
|
])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(1);
|
expect(rootNodes.length).toBe(1);
|
||||||
expect(getDOM().nodeName(rootNodes[0]).toLowerCase()).toBe('span');
|
expect(getDOM().nodeName(rootNodes[0]).toLowerCase()).toBe('span');
|
||||||
|
@ -57,16 +57,16 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
it('should create views with multiple root elements', () => {
|
it('should create views with multiple root elements', () => {
|
||||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 0, 'span'),
|
elementDef(NodeFlags.None, null, null, 0, 'span'),
|
||||||
elementDef(NodeFlags.None, null, 0, 'span')
|
elementDef(NodeFlags.None, null, null, 0, 'span')
|
||||||
])).rootNodes;
|
])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(2);
|
expect(rootNodes.length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create elements with parents', () => {
|
it('should create elements with parents', () => {
|
||||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
elementDef(NodeFlags.None, null, 0, 'span'),
|
elementDef(NodeFlags.None, null, null, 0, 'span'),
|
||||||
])).rootNodes;
|
])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(1);
|
expect(rootNodes.length).toBe(1);
|
||||||
const spanEl = getDOM().childNodes(rootNodes[0])[0];
|
const spanEl = getDOM().childNodes(rootNodes[0])[0];
|
||||||
|
@ -75,7 +75,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
it('should set fixed attributes', () => {
|
it('should set fixed attributes', () => {
|
||||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 0, 'div', {'title': 'a'}),
|
elementDef(NodeFlags.None, null, null, 0, 'div', {'title': 'a'}),
|
||||||
])).rootNodes;
|
])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(1);
|
expect(rootNodes.length).toBe(1);
|
||||||
expect(getDOM().getAttribute(rootNodes[0], 'title')).toBe('a');
|
expect(getDOM().getAttribute(rootNodes[0], 'title')).toBe('a');
|
||||||
|
@ -85,7 +85,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
it('should add debug information to the renderer', () => {
|
it('should add debug information to the renderer', () => {
|
||||||
const someContext = new Object();
|
const someContext = new Object();
|
||||||
const {view, rootNodes} = createAndGetRootNodes(
|
const {view, rootNodes} = createAndGetRootNodes(
|
||||||
compViewDef([elementDef(NodeFlags.None, null, 0, 'div')]), someContext);
|
compViewDef([elementDef(NodeFlags.None, null, null, 0, 'div')]), someContext);
|
||||||
expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asElementData(view, 0).renderElement);
|
expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asElementData(view, 0).renderElement);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(
|
elementDef(
|
||||||
NodeFlags.None, null, 0, 'input', null,
|
NodeFlags.None, null, null, 0, 'input', null,
|
||||||
[
|
[
|
||||||
[BindingType.ElementProperty, 'title', SecurityContext.NONE],
|
[BindingType.ElementProperty, 'title', SecurityContext.NONE],
|
||||||
[BindingType.ElementProperty, 'value', SecurityContext.NONE]
|
[BindingType.ElementProperty, 'value', SecurityContext.NONE]
|
||||||
|
@ -128,7 +128,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(
|
elementDef(
|
||||||
NodeFlags.None, null, 0, 'div', null,
|
NodeFlags.None, null, null, 0, 'div', null,
|
||||||
[
|
[
|
||||||
[BindingType.ElementAttribute, 'a1', SecurityContext.NONE],
|
[BindingType.ElementAttribute, 'a1', SecurityContext.NONE],
|
||||||
[BindingType.ElementAttribute, 'a2', SecurityContext.NONE]
|
[BindingType.ElementAttribute, 'a2', SecurityContext.NONE]
|
||||||
|
@ -154,7 +154,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(
|
elementDef(
|
||||||
NodeFlags.None, null, 0, 'div', null,
|
NodeFlags.None, null, null, 0, 'div', null,
|
||||||
[[BindingType.ElementClass, 'c1'], [BindingType.ElementClass, 'c2']]),
|
[[BindingType.ElementClass, 'c1'], [BindingType.ElementClass, 'c2']]),
|
||||||
],
|
],
|
||||||
(view) => {
|
(view) => {
|
||||||
|
@ -177,7 +177,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(
|
elementDef(
|
||||||
NodeFlags.None, null, 0, 'div', null,
|
NodeFlags.None, null, null, 0, 'div', null,
|
||||||
[
|
[
|
||||||
[BindingType.ElementStyle, 'width', 'px'],
|
[BindingType.ElementStyle, 'width', 'px'],
|
||||||
[BindingType.ElementStyle, 'color', null]
|
[BindingType.ElementStyle, 'color', null]
|
||||||
|
@ -226,7 +226,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
const removeListenerSpy =
|
const removeListenerSpy =
|
||||||
spyOn(HTMLElement.prototype, 'removeEventListener').and.callThrough();
|
spyOn(HTMLElement.prototype, 'removeEventListener').and.callThrough();
|
||||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
||||||
[elementDef(NodeFlags.None, null, 0, 'button', null, null, ['click'])], null,
|
[elementDef(NodeFlags.None, null, null, 0, 'button', null, null, ['click'])], null,
|
||||||
handleEventSpy));
|
handleEventSpy));
|
||||||
|
|
||||||
rootNodes[0].click();
|
rootNodes[0].click();
|
||||||
|
@ -249,7 +249,8 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
const removeListenerSpy = spyOn(window, 'removeEventListener');
|
const removeListenerSpy = spyOn(window, 'removeEventListener');
|
||||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
||||||
[elementDef(
|
[elementDef(
|
||||||
NodeFlags.None, null, 0, 'button', null, null, [['window', 'windowClick']])],
|
NodeFlags.None, null, null, 0, 'button', null, null,
|
||||||
|
[['window', 'windowClick']])],
|
||||||
null, handleEventSpy));
|
null, handleEventSpy));
|
||||||
|
|
||||||
expect(addListenerSpy).toHaveBeenCalled();
|
expect(addListenerSpy).toHaveBeenCalled();
|
||||||
|
@ -274,7 +275,8 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
const removeListenerSpy = spyOn(document, 'removeEventListener');
|
const removeListenerSpy = spyOn(document, 'removeEventListener');
|
||||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
||||||
[elementDef(
|
[elementDef(
|
||||||
NodeFlags.None, null, 0, 'button', null, null, [['document', 'documentClick']])],
|
NodeFlags.None, null, null, 0, 'button', null, null,
|
||||||
|
[['document', 'documentClick']])],
|
||||||
null, handleEventSpy));
|
null, handleEventSpy));
|
||||||
|
|
||||||
expect(addListenerSpy).toHaveBeenCalled();
|
expect(addListenerSpy).toHaveBeenCalled();
|
||||||
|
@ -298,7 +300,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
let preventDefaultSpy: jasmine.Spy;
|
let preventDefaultSpy: jasmine.Spy;
|
||||||
|
|
||||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
||||||
[elementDef(NodeFlags.None, null, 0, 'button', null, null, ['click'])], null,
|
[elementDef(NodeFlags.None, null, null, 0, 'button', null, null, ['click'])], null,
|
||||||
(view, index, eventName, event) => {
|
(view, index, eventName, event) => {
|
||||||
preventDefaultSpy = spyOn(event, 'preventDefault').and.callThrough();
|
preventDefaultSpy = spyOn(event, 'preventDefault').and.callThrough();
|
||||||
return eventHandlerResult;
|
return eventHandlerResult;
|
||||||
|
@ -324,7 +326,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
it('should report debug info on event errors', () => {
|
it('should report debug info on event errors', () => {
|
||||||
const addListenerSpy = spyOn(HTMLElement.prototype, 'addEventListener').and.callThrough();
|
const addListenerSpy = spyOn(HTMLElement.prototype, 'addEventListener').and.callThrough();
|
||||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
|
||||||
[elementDef(NodeFlags.None, null, 0, 'button', null, null, ['click'])], null,
|
[elementDef(NodeFlags.None, null, null, 0, 'button', null, null, ['click'])], null,
|
||||||
() => { throw new Error('Test'); }));
|
() => { throw new Error('Test'); }));
|
||||||
|
|
||||||
let err: any;
|
let err: any;
|
||||||
|
|
|
@ -56,9 +56,10 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
const {view: parentView, rootNodes} = createAndGetRootNodes(
|
const {view: parentView, rootNodes} = createAndGetRootNodes(
|
||||||
compViewDef([
|
compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 2, 'div'),
|
elementDef(NodeFlags.None, null, null, 2, 'div'),
|
||||||
anchorDef(NodeFlags.HasEmbeddedViews, null, 0, embeddedViewDef([elementDef(
|
anchorDef(
|
||||||
NodeFlags.None, null, 0, 'span')])),
|
NodeFlags.HasEmbeddedViews, null, null, 0,
|
||||||
|
embeddedViewDef([elementDef(NodeFlags.None, null, null, 0, 'span')])),
|
||||||
]),
|
]),
|
||||||
parentContext);
|
parentContext);
|
||||||
|
|
||||||
|
@ -69,13 +70,13 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
it('should attach and detach embedded views', () => {
|
it('should attach and detach embedded views', () => {
|
||||||
const {view: parentView, rootNodes} = createAndGetRootNodes(compViewDef([
|
const {view: parentView, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 2, 'div'),
|
elementDef(NodeFlags.None, null, null, 2, 'div'),
|
||||||
anchorDef(
|
anchorDef(NodeFlags.HasEmbeddedViews, null, null, 0, embeddedViewDef([
|
||||||
NodeFlags.HasEmbeddedViews, null, 0,
|
elementDef(NodeFlags.None, null, null, 0, 'span', {'name': 'child0'})
|
||||||
embeddedViewDef([elementDef(NodeFlags.None, null, 0, 'span', {'name': 'child0'})])),
|
])),
|
||||||
anchorDef(
|
anchorDef(NodeFlags.None, null, null, 0, embeddedViewDef([
|
||||||
NodeFlags.None, null, 0,
|
elementDef(NodeFlags.None, null, null, 0, 'span', {'name': 'child1'})
|
||||||
embeddedViewDef([elementDef(NodeFlags.None, null, 0, 'span', {'name': 'child1'})]))
|
]))
|
||||||
]));
|
]));
|
||||||
|
|
||||||
const childView0 = createEmbeddedView(parentView, parentView.def.nodes[1]);
|
const childView0 = createEmbeddedView(parentView, parentView.def.nodes[1]);
|
||||||
|
@ -99,10 +100,10 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
it('should include embedded views in root nodes', () => {
|
it('should include embedded views in root nodes', () => {
|
||||||
const {view: parentView} = createAndGetRootNodes(compViewDef([
|
const {view: parentView} = createAndGetRootNodes(compViewDef([
|
||||||
anchorDef(
|
anchorDef(NodeFlags.HasEmbeddedViews, null, null, 0, embeddedViewDef([
|
||||||
NodeFlags.HasEmbeddedViews, null, 0,
|
elementDef(NodeFlags.None, null, null, 0, 'span', {'name': 'child0'})
|
||||||
embeddedViewDef([elementDef(NodeFlags.None, null, 0, 'span', {'name': 'child0'})])),
|
])),
|
||||||
elementDef(NodeFlags.None, null, 0, 'span', {'name': 'after'})
|
elementDef(NodeFlags.None, null, null, 0, 'span', {'name': 'after'})
|
||||||
]));
|
]));
|
||||||
|
|
||||||
const childView0 = createEmbeddedView(parentView, parentView.def.nodes[0]);
|
const childView0 = createEmbeddedView(parentView, parentView.def.nodes[0]);
|
||||||
|
@ -122,12 +123,12 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const {view: parentView, rootNodes} = createAndGetRootNodes(compViewDef([
|
const {view: parentView, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
anchorDef(
|
anchorDef(
|
||||||
NodeFlags.HasEmbeddedViews, null, 0,
|
NodeFlags.HasEmbeddedViews, null, null, 0,
|
||||||
embeddedViewDef(
|
embeddedViewDef(
|
||||||
[elementDef(
|
[elementDef(
|
||||||
NodeFlags.None, null, 0, 'span', null,
|
NodeFlags.None, null, null, 0, 'span', null,
|
||||||
[[BindingType.ElementAttribute, 'name', SecurityContext.NONE]])],
|
[[BindingType.ElementAttribute, 'name', SecurityContext.NONE]])],
|
||||||
update))
|
update))
|
||||||
]));
|
]));
|
||||||
|
@ -160,9 +161,9 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view: parentView, rootNodes} = createAndGetRootNodes(compViewDef([
|
const {view: parentView, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
anchorDef(NodeFlags.HasEmbeddedViews, null, 0, embeddedViewDef([
|
anchorDef(NodeFlags.HasEmbeddedViews, null, null, 0, embeddedViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.OnDestroy, null, 0, ChildProvider, [])
|
providerDef(NodeFlags.OnDestroy, null, 0, ChildProvider, [])
|
||||||
]))
|
]))
|
||||||
]));
|
]));
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {RenderComponentType, RootRenderer, Sanitizer, SecurityContext, TemplateRef, ViewContainerRef, ViewEncapsulation, getDebugNode} from '@angular/core';
|
||||||
|
import {DebugContext, DefaultServices, NodeDef, NodeFlags, Services, ViewData, ViewDefinition, ViewFlags, ViewHandleEventFn, ViewUpdateFn, anchorDef, asElementData, asProviderData, asTextData, attachEmbeddedView, checkAndUpdateView, checkNoChangesView, checkNodeDynamic, checkNodeInline, createEmbeddedView, createRootView, detachEmbeddedView, elementDef, ngContentDef, providerDef, rootRenderNodes, setCurrentNode, textDef, viewDef} from '@angular/core/src/view/index';
|
||||||
|
import {inject} from '@angular/core/testing';
|
||||||
|
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||||
|
|
||||||
|
import {isBrowser, setupAndCheckRenderer} from './helper';
|
||||||
|
|
||||||
|
export function main() {
|
||||||
|
if (isBrowser()) {
|
||||||
|
defineTests({directDom: true, viewFlags: ViewFlags.DirectDom});
|
||||||
|
}
|
||||||
|
defineTests({directDom: false, viewFlags: 0});
|
||||||
|
}
|
||||||
|
|
||||||
|
function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
describe(`View NgContent, directDom: ${config.directDom}`, () => {
|
||||||
|
setupAndCheckRenderer(config);
|
||||||
|
|
||||||
|
let services: Services;
|
||||||
|
let renderComponentType: RenderComponentType;
|
||||||
|
|
||||||
|
beforeEach(
|
||||||
|
inject([RootRenderer, Sanitizer], (rootRenderer: RootRenderer, sanitizer: Sanitizer) => {
|
||||||
|
services = new DefaultServices(rootRenderer, sanitizer);
|
||||||
|
renderComponentType =
|
||||||
|
new RenderComponentType('1', 'someUrl', 0, ViewEncapsulation.None, [], {});
|
||||||
|
}));
|
||||||
|
|
||||||
|
function compViewDef(
|
||||||
|
nodes: NodeDef[], update?: ViewUpdateFn, handleEvent?: ViewHandleEventFn): ViewDefinition {
|
||||||
|
return viewDef(config.viewFlags, nodes, update, handleEvent, renderComponentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
function embeddedViewDef(nodes: NodeDef[], update?: ViewUpdateFn): ViewDefinition {
|
||||||
|
return viewDef(config.viewFlags, nodes, update);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hostElDef(contentNodes: NodeDef[], viewNodes: NodeDef[]): NodeDef[] {
|
||||||
|
class AComp {}
|
||||||
|
|
||||||
|
const aCompViewDef = compViewDef(viewNodes);
|
||||||
|
|
||||||
|
return [
|
||||||
|
elementDef(NodeFlags.None, null, null, 1 + contentNodes.length, 'acomp'),
|
||||||
|
providerDef(NodeFlags.None, null, 0, AComp, [], null, null, () => aCompViewDef),
|
||||||
|
...contentNodes
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAndGetRootNodes(
|
||||||
|
viewDef: ViewDefinition, ctx?: any): {rootNodes: any[], view: ViewData} {
|
||||||
|
const view = createRootView(services, () => viewDef, ctx || {});
|
||||||
|
const rootNodes = rootRenderNodes(view);
|
||||||
|
return {rootNodes, view};
|
||||||
|
}
|
||||||
|
|
||||||
|
it('should create ng-content nodes without parents', () => {
|
||||||
|
const {view, rootNodes} = createAndGetRootNodes(
|
||||||
|
compViewDef(hostElDef([textDef(0, ['a'])], [ngContentDef(null, 0)])));
|
||||||
|
|
||||||
|
expect(getDOM().firstChild(rootNodes[0])).toBe(asTextData(view, 2).renderText);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create views with multiple root ng-content nodes', () => {
|
||||||
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef(
|
||||||
|
[textDef(0, ['a']), textDef(1, ['b'])], [ngContentDef(null, 0), ngContentDef(null, 1)])));
|
||||||
|
|
||||||
|
expect(getDOM().childNodes(rootNodes[0])[0]).toBe(asTextData(view, 2).renderText);
|
||||||
|
expect(getDOM().childNodes(rootNodes[0])[1]).toBe(asTextData(view, 3).renderText);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create ng-content nodes with parents', () => {
|
||||||
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef(
|
||||||
|
[textDef(0, ['a'])],
|
||||||
|
[elementDef(NodeFlags.None, null, null, 1, 'div'), ngContentDef(null, 0)])));
|
||||||
|
|
||||||
|
expect(getDOM().firstChild(getDOM().firstChild(rootNodes[0])))
|
||||||
|
.toBe(asTextData(view, 2).renderText);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reproject ng-content nodes', () => {
|
||||||
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
|
hostElDef([textDef(0, ['a'])], hostElDef([ngContentDef(0, 0)], [
|
||||||
|
elementDef(NodeFlags.None, null, null, 1, 'span'), ngContentDef(null, 0)
|
||||||
|
]))));
|
||||||
|
expect(getDOM().firstChild(getDOM().firstChild(getDOM().firstChild(rootNodes[0]))))
|
||||||
|
.toBe(asTextData(view, 2).renderText);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should project already attached embedded views', () => {
|
||||||
|
class CreateViewService {
|
||||||
|
constructor(templateRef: TemplateRef<any>, viewContainerRef: ViewContainerRef) {
|
||||||
|
viewContainerRef.createEmbeddedView(templateRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef(
|
||||||
|
[
|
||||||
|
anchorDef(
|
||||||
|
NodeFlags.HasEmbeddedViews, null, 0, 1, embeddedViewDef([textDef(null, ['a'])])),
|
||||||
|
providerDef(
|
||||||
|
NodeFlags.None, null, 0, CreateViewService, [TemplateRef, ViewContainerRef])
|
||||||
|
],
|
||||||
|
[elementDef(NodeFlags.None, null, null, 1, 'div'), ngContentDef(null, 0)])));
|
||||||
|
|
||||||
|
const anchor = asElementData(view, 2);
|
||||||
|
expect((getDOM().childNodes(getDOM().firstChild(rootNodes[0]))[0]))
|
||||||
|
.toBe(anchor.renderElement);
|
||||||
|
const embeddedView = anchor.embeddedViews[0];
|
||||||
|
expect((getDOM().childNodes(getDOM().firstChild(rootNodes[0]))[1]))
|
||||||
|
.toBe(asTextData(embeddedView, 0).renderText);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should include projected nodes when attaching / detaching embedded views', () => {
|
||||||
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef([textDef(0, ['a'])], [
|
||||||
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
|
anchorDef(NodeFlags.HasEmbeddedViews, null, 0, 0, embeddedViewDef([ngContentDef(null, 0)])),
|
||||||
|
])));
|
||||||
|
|
||||||
|
const componentView = asProviderData(view, 1).componentView;
|
||||||
|
const view0 = createEmbeddedView(componentView, componentView.def.nodes[1]);
|
||||||
|
|
||||||
|
attachEmbeddedView(asElementData(componentView, 1), 0, view0);
|
||||||
|
expect(getDOM().childNodes(getDOM().firstChild(rootNodes[0])).length).toBe(2);
|
||||||
|
expect(getDOM().childNodes(getDOM().firstChild(rootNodes[0]))[1])
|
||||||
|
.toBe(asTextData(view, 2).renderText);
|
||||||
|
|
||||||
|
detachEmbeddedView(asElementData(componentView, 1), 0);
|
||||||
|
expect(getDOM().childNodes(getDOM().firstChild(rootNodes[0])).length).toBe(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -57,7 +57,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
createAndGetRootNodes(compViewDef([
|
createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [])
|
providerDef(NodeFlags.None, null, 0, SomeService, [])
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
let err: any;
|
let err: any;
|
||||||
try {
|
try {
|
||||||
createAndGetRootNodes(compViewDef([
|
createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [])
|
providerDef(NodeFlags.None, null, 0, SomeService, [])
|
||||||
]));
|
]));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -98,7 +98,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
it('should inject deps from the same element', () => {
|
it('should inject deps from the same element', () => {
|
||||||
createAndGetRootNodes(compViewDef([
|
createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, Dep, []),
|
providerDef(NodeFlags.None, null, 0, Dep, []),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
providerDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
||||||
]));
|
]));
|
||||||
|
@ -108,9 +108,9 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
it('should inject deps from a parent element', () => {
|
it('should inject deps from a parent element', () => {
|
||||||
createAndGetRootNodes(compViewDef([
|
createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 3, 'span'),
|
elementDef(NodeFlags.None, null, null, 3, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, Dep, []),
|
providerDef(NodeFlags.None, null, 0, Dep, []),
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
providerDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -119,9 +119,9 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
it('should not inject deps from sibling root elements', () => {
|
it('should not inject deps from sibling root elements', () => {
|
||||||
const nodes = [
|
const nodes = [
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, Dep, []),
|
providerDef(NodeFlags.None, null, 0, Dep, []),
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
providerDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -132,17 +132,17 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
// non root elements
|
// non root elements
|
||||||
expect(
|
expect(
|
||||||
() => createAndGetRootNodes(
|
() => createAndGetRootNodes(
|
||||||
compViewDef([elementDef(NodeFlags.None, null, 4, 'span')].concat(nodes))))
|
compViewDef([elementDef(NodeFlags.None, null, null, 4, 'span')].concat(nodes))))
|
||||||
.toThrowError('No provider for Dep!');
|
.toThrowError('No provider for Dep!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inject from a parent elment in a parent view', () => {
|
it('should inject from a parent elment in a parent view', () => {
|
||||||
createAndGetRootNodes(compViewDef([
|
createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, Dep, [], null, null,
|
NodeFlags.None, null, 0, Dep, [], null, null,
|
||||||
() => compViewDef([
|
() => compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
providerDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
||||||
])),
|
])),
|
||||||
]));
|
]));
|
||||||
|
@ -153,7 +153,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
describe('builtin tokens', () => {
|
describe('builtin tokens', () => {
|
||||||
it('should inject ViewContainerRef', () => {
|
it('should inject ViewContainerRef', () => {
|
||||||
createAndGetRootNodes(compViewDef([
|
createAndGetRootNodes(compViewDef([
|
||||||
anchorDef(NodeFlags.HasEmbeddedViews, null, 1),
|
anchorDef(NodeFlags.HasEmbeddedViews, null, null, 1),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [ViewContainerRef])
|
providerDef(NodeFlags.None, null, 0, SomeService, [ViewContainerRef])
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -162,8 +162,8 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
it('should inject TemplateRef', () => {
|
it('should inject TemplateRef', () => {
|
||||||
createAndGetRootNodes(compViewDef([
|
createAndGetRootNodes(compViewDef([
|
||||||
anchorDef(
|
anchorDef(NodeFlags.None, null, null, 1, embeddedViewDef([anchorDef(
|
||||||
NodeFlags.None, null, 1, embeddedViewDef([anchorDef(NodeFlags.None, null, 0)])),
|
NodeFlags.None, null, null, 0)])),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [TemplateRef])
|
providerDef(NodeFlags.None, null, 0, SomeService, [TemplateRef])
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
it('should inject ElementRef', () => {
|
it('should inject ElementRef', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [ElementRef])
|
providerDef(NodeFlags.None, null, 0, SomeService, [ElementRef])
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
if (config.directDom) {
|
if (config.directDom) {
|
||||||
it('should not inject Renderer when using directDom', () => {
|
it('should not inject Renderer when using directDom', () => {
|
||||||
expect(() => createAndGetRootNodes(compViewDef([
|
expect(() => createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [Renderer])
|
providerDef(NodeFlags.None, null, 0, SomeService, [Renderer])
|
||||||
])))
|
])))
|
||||||
.toThrowError('No provider for Renderer!');
|
.toThrowError('No provider for Renderer!');
|
||||||
|
@ -190,7 +190,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
} else {
|
} else {
|
||||||
it('should inject Renderer when not using directDom', () => {
|
it('should inject Renderer when not using directDom', () => {
|
||||||
createAndGetRootNodes(compViewDef([
|
createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [Renderer])
|
providerDef(NodeFlags.None, null, 0, SomeService, [Renderer])
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomeService, [], {a: [0, 'a'], b: [1, 'b']})
|
providerDef(NodeFlags.None, null, 0, SomeService, [], {a: [0, 'a'], b: [1, 'b']})
|
||||||
],
|
],
|
||||||
(view) => {
|
(view) => {
|
||||||
|
@ -257,7 +257,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, SomeService, [], null, {emitter: 'someEventName'})
|
NodeFlags.None, null, 0, SomeService, [], null, {emitter: 'someEventName'})
|
||||||
],
|
],
|
||||||
|
@ -279,7 +279,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, SomeService, [], null, {emitter: 'someEventName'})
|
NodeFlags.None, null, 0, SomeService, [], null, {emitter: 'someEventName'})
|
||||||
],
|
],
|
||||||
|
@ -324,9 +324,9 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
NodeFlags.AfterViewChecked | NodeFlags.OnDestroy;
|
NodeFlags.AfterViewChecked | NodeFlags.OnDestroy;
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 3, 'span'),
|
elementDef(NodeFlags.None, null, null, 3, 'span'),
|
||||||
providerDef(allFlags, null, 0, SomeService, [], {a: [0, 'a']}),
|
providerDef(allFlags, null, 0, SomeService, [], {a: [0, 'a']}),
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(allFlags, null, 0, SomeService, [], {a: [0, 'a']})
|
providerDef(allFlags, null, 0, SomeService, [], {a: [0, 'a']})
|
||||||
],
|
],
|
||||||
(updater) => {
|
(updater) => {
|
||||||
|
@ -385,7 +385,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.OnChanges, null, 0, SomeService, [], {a: [0, 'nonMinifiedA']})
|
providerDef(NodeFlags.OnChanges, null, 0, SomeService, [], {a: [0, 'nonMinifiedA']})
|
||||||
],
|
],
|
||||||
(updater) => {
|
(updater) => {
|
||||||
|
@ -408,7 +408,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.AfterContentChecked, null, 0, SomeService, [], {a: [0, 'a']}),
|
providerDef(NodeFlags.AfterContentChecked, null, 0, SomeService, [], {a: [0, 'a']}),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.OnDestroy, null, 0, SomeService, [], {a: [0, 'a']}),
|
providerDef(NodeFlags.OnDestroy, null, 0, SomeService, [], {a: [0, 'a']}),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ export function main() {
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'), pureArrayDef(2),
|
elementDef(NodeFlags.None, null, null, 2, 'span'), pureArrayDef(2),
|
||||||
providerDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
|
providerDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
|
||||||
],
|
],
|
||||||
(view) => {
|
(view) => {
|
||||||
|
@ -80,7 +80,7 @@ export function main() {
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'), pureObjectDef(['a', 'b']),
|
elementDef(NodeFlags.None, null, null, 2, 'span'), pureObjectDef(['a', 'b']),
|
||||||
providerDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
|
providerDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
|
||||||
],
|
],
|
||||||
(view) => {
|
(view) => {
|
||||||
|
@ -119,7 +119,7 @@ export function main() {
|
||||||
|
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 3, 'span'),
|
elementDef(NodeFlags.None, null, null, 3, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, SomePipe, []), purePipeDef(SomePipe, 2),
|
providerDef(NodeFlags.None, null, 0, SomePipe, []), purePipeDef(SomePipe, 2),
|
||||||
providerDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
|
providerDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
|
||||||
],
|
],
|
||||||
|
|
|
@ -67,10 +67,10 @@ export function main() {
|
||||||
|
|
||||||
it('should query providers on the same element and child elements', () => {
|
it('should query providers on the same element and child elements', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 5, 'div'),
|
elementDef(NodeFlags.None, null, null, 5, 'div'),
|
||||||
...contentQueryProviders(),
|
...contentQueryProviders(),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -87,11 +87,11 @@ export function main() {
|
||||||
|
|
||||||
it('should not query providers on sibling or parent elements', () => {
|
it('should not query providers on sibling or parent elements', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 6, 'div'),
|
elementDef(NodeFlags.None, null, null, 6, 'div'),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
elementDef(NodeFlags.None, null, 2, 'div'),
|
elementDef(NodeFlags.None, null, null, 2, 'div'),
|
||||||
...contentQueryProviders(),
|
...contentQueryProviders(),
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@ export function main() {
|
||||||
describe('view queries', () => {
|
describe('view queries', () => {
|
||||||
it('should query providers in the view', () => {
|
it('should query providers in the view', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 2, 'div'),
|
elementDef(NodeFlags.None, null, null, 2, 'div'),
|
||||||
...viewQueryProviders(compViewDef([
|
...viewQueryProviders(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
])),
|
])),
|
||||||
]));
|
]));
|
||||||
|
@ -122,9 +122,9 @@ export function main() {
|
||||||
|
|
||||||
it('should not query providers on the host element', () => {
|
it('should not query providers on the host element', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 3, 'div'),
|
elementDef(NodeFlags.None, null, null, 3, 'div'),
|
||||||
...viewQueryProviders(compViewDef([
|
...viewQueryProviders(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
])),
|
])),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
]));
|
]));
|
||||||
|
@ -138,15 +138,16 @@ export function main() {
|
||||||
describe('embedded views', () => {
|
describe('embedded views', () => {
|
||||||
it('should query providers in embedded views', () => {
|
it('should query providers in embedded views', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 5, 'div'),
|
elementDef(NodeFlags.None, null, null, 5, 'div'),
|
||||||
...contentQueryProviders(),
|
...contentQueryProviders(),
|
||||||
anchorDef(
|
anchorDef(
|
||||||
NodeFlags.HasEmbeddedViews, null, 2, viewDef(
|
NodeFlags.HasEmbeddedViews, null, null, 2,
|
||||||
ViewFlags.None,
|
viewDef(
|
||||||
[
|
ViewFlags.None,
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
[
|
||||||
aServiceProvider(),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
])),
|
aServiceProvider(),
|
||||||
|
])),
|
||||||
...contentQueryProviders(),
|
...contentQueryProviders(),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
@ -167,18 +168,19 @@ export function main() {
|
||||||
|
|
||||||
it('should query providers in embedded views only at the template declaration', () => {
|
it('should query providers in embedded views only at the template declaration', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 3, 'div'),
|
elementDef(NodeFlags.None, null, null, 3, 'div'),
|
||||||
...contentQueryProviders(),
|
...contentQueryProviders(),
|
||||||
anchorDef(
|
anchorDef(
|
||||||
NodeFlags.HasEmbeddedViews, null, 0, viewDef(
|
NodeFlags.HasEmbeddedViews, null, null, 0,
|
||||||
ViewFlags.None,
|
viewDef(
|
||||||
[
|
ViewFlags.None,
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
[
|
||||||
aServiceProvider(),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
])),
|
aServiceProvider(),
|
||||||
elementDef(NodeFlags.None, null, 3, 'div'),
|
])),
|
||||||
|
elementDef(NodeFlags.None, null, null, 3, 'div'),
|
||||||
...contentQueryProviders(),
|
...contentQueryProviders(),
|
||||||
anchorDef(NodeFlags.HasEmbeddedViews, null, 0),
|
anchorDef(NodeFlags.HasEmbeddedViews, null, null, 0),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
const childView = createEmbeddedView(view, view.def.nodes[3]);
|
const childView = createEmbeddedView(view, view.def.nodes[3]);
|
||||||
|
@ -199,15 +201,16 @@ export function main() {
|
||||||
|
|
||||||
it('should update content queries if embedded views are added or removed', () => {
|
it('should update content queries if embedded views are added or removed', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 3, 'div'),
|
elementDef(NodeFlags.None, null, null, 3, 'div'),
|
||||||
...contentQueryProviders(),
|
...contentQueryProviders(),
|
||||||
anchorDef(
|
anchorDef(
|
||||||
NodeFlags.HasEmbeddedViews, null, 0, viewDef(
|
NodeFlags.HasEmbeddedViews, null, null, 0,
|
||||||
ViewFlags.None,
|
viewDef(
|
||||||
[
|
ViewFlags.None,
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
[
|
||||||
aServiceProvider(),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
])),
|
aServiceProvider(),
|
||||||
|
])),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
checkAndUpdateView(view);
|
checkAndUpdateView(view);
|
||||||
|
@ -229,14 +232,14 @@ export function main() {
|
||||||
|
|
||||||
it('should update view queries if embedded views are added or removed', () => {
|
it('should update view queries if embedded views are added or removed', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 2, 'div'),
|
elementDef(NodeFlags.None, null, null, 2, 'div'),
|
||||||
...viewQueryProviders(compViewDef([
|
...viewQueryProviders(compViewDef([
|
||||||
anchorDef(
|
anchorDef(
|
||||||
NodeFlags.HasEmbeddedViews, null, 0,
|
NodeFlags.HasEmbeddedViews, null, null, 0,
|
||||||
viewDef(
|
viewDef(
|
||||||
ViewFlags.None,
|
ViewFlags.None,
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
])),
|
])),
|
||||||
])),
|
])),
|
||||||
|
@ -268,7 +271,7 @@ export function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 4, 'div'),
|
elementDef(NodeFlags.None, null, null, 4, 'div'),
|
||||||
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
||||||
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.All}),
|
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.All}),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
|
@ -291,7 +294,7 @@ export function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 4, 'div'),
|
elementDef(NodeFlags.None, null, null, 4, 'div'),
|
||||||
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
||||||
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.First}),
|
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.First}),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
|
@ -312,7 +315,7 @@ export function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, [['query1', QueryValueType.ElementRef]], 2, 'div'),
|
elementDef(NodeFlags.None, [['query1', QueryValueType.ElementRef]], null, 2, 'div'),
|
||||||
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
||||||
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.First}),
|
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.First}),
|
||||||
]));
|
]));
|
||||||
|
@ -330,8 +333,8 @@ export function main() {
|
||||||
|
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
anchorDef(
|
anchorDef(
|
||||||
NodeFlags.None, [['query1', QueryValueType.TemplateRef]], 2,
|
NodeFlags.None, [['query1', QueryValueType.TemplateRef]], null, 2,
|
||||||
viewDef(ViewFlags.None, [anchorDef(NodeFlags.None, null, 0)])),
|
viewDef(ViewFlags.None, [anchorDef(NodeFlags.None, null, null, 0)])),
|
||||||
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
||||||
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.First}),
|
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.First}),
|
||||||
]));
|
]));
|
||||||
|
@ -348,7 +351,7 @@ export function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
anchorDef(NodeFlags.None, [['query1', QueryValueType.ViewContainerRef]], 2),
|
anchorDef(NodeFlags.None, [['query1', QueryValueType.ViewContainerRef]], null, 2),
|
||||||
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
||||||
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.First}),
|
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.First}),
|
||||||
]));
|
]));
|
||||||
|
@ -363,15 +366,16 @@ export function main() {
|
||||||
describe('general binding behavior', () => {
|
describe('general binding behavior', () => {
|
||||||
it('should checkNoChanges', () => {
|
it('should checkNoChanges', () => {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 4, 'div'),
|
elementDef(NodeFlags.None, null, null, 4, 'div'),
|
||||||
...contentQueryProviders(),
|
...contentQueryProviders(),
|
||||||
anchorDef(
|
anchorDef(
|
||||||
NodeFlags.HasEmbeddedViews, null, 1, viewDef(
|
NodeFlags.HasEmbeddedViews, null, null, 1,
|
||||||
ViewFlags.None,
|
viewDef(
|
||||||
[
|
ViewFlags.None,
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
[
|
||||||
aServiceProvider(),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
])),
|
aServiceProvider(),
|
||||||
|
])),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
checkAndUpdateView(view);
|
checkAndUpdateView(view);
|
||||||
|
@ -401,7 +405,7 @@ export function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 3, 'div'),
|
elementDef(NodeFlags.None, null, null, 3, 'div'),
|
||||||
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
providerDef(NodeFlags.None, null, 1, QueryService, []),
|
||||||
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.All}),
|
queryDef(NodeFlags.HasContentQuery, 'query1', {'a': QueryBindingType.All}),
|
||||||
aServiceProvider(),
|
aServiceProvider(),
|
||||||
|
|
|
@ -44,12 +44,12 @@ export function main() {
|
||||||
|
|
||||||
function createViewWithData() {
|
function createViewWithData() {
|
||||||
const {view} = createAndGetRootNodes(compViewDef([
|
const {view} = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, AComp, [], null, null,
|
NodeFlags.None, null, 0, AComp, [], null, null,
|
||||||
() => compViewDef([
|
() => compViewDef([
|
||||||
elementDef(NodeFlags.None, [['#ref', QueryValueType.ElementRef]], 2, 'span'),
|
elementDef(NodeFlags.None, [['#ref', QueryValueType.ElementRef]], null, 2, 'span'),
|
||||||
providerDef(NodeFlags.None, null, 0, AService, []), textDef(['a'])
|
providerDef(NodeFlags.None, null, 0, AService, []), textDef(null, ['a'])
|
||||||
])),
|
])),
|
||||||
]));
|
]));
|
||||||
return view;
|
return view;
|
||||||
|
|
|
@ -48,21 +48,22 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
|
|
||||||
describe('create', () => {
|
describe('create', () => {
|
||||||
it('should create text nodes without parents', () => {
|
it('should create text nodes without parents', () => {
|
||||||
const rootNodes = createAndGetRootNodes(compViewDef([textDef(['a'])])).rootNodes;
|
const rootNodes = createAndGetRootNodes(compViewDef([textDef(null, ['a'])])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(1);
|
expect(rootNodes.length).toBe(1);
|
||||||
expect(getDOM().getText(rootNodes[0])).toBe('a');
|
expect(getDOM().getText(rootNodes[0])).toBe('a');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create views with multiple root text nodes', () => {
|
it('should create views with multiple root text nodes', () => {
|
||||||
const rootNodes =
|
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||||
createAndGetRootNodes(compViewDef([textDef(['a']), textDef(['b'])])).rootNodes;
|
textDef(null, ['a']), textDef(null, ['b'])
|
||||||
|
])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(2);
|
expect(rootNodes.length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create text nodes with parents', () => {
|
it('should create text nodes with parents', () => {
|
||||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||||
elementDef(NodeFlags.None, null, 1, 'div'),
|
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||||
textDef(['a']),
|
textDef(null, ['a']),
|
||||||
])).rootNodes;
|
])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(1);
|
expect(rootNodes.length).toBe(1);
|
||||||
const textNode = getDOM().firstChild(rootNodes[0]);
|
const textNode = getDOM().firstChild(rootNodes[0]);
|
||||||
|
@ -73,7 +74,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
it('should add debug information to the renderer', () => {
|
it('should add debug information to the renderer', () => {
|
||||||
const someContext = new Object();
|
const someContext = new Object();
|
||||||
const {view, rootNodes} =
|
const {view, rootNodes} =
|
||||||
createAndGetRootNodes(compViewDef([textDef(['a'])]), someContext);
|
createAndGetRootNodes(compViewDef([textDef(null, ['a'])]), someContext);
|
||||||
expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asTextData(view, 0).renderText);
|
expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asTextData(view, 0).renderText);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -84,7 +85,7 @@ function defineTests(config: {directDom: boolean, viewFlags: number}) {
|
||||||
it(`should update ${InlineDynamic[inlineDynamic]}`, () => {
|
it(`should update ${InlineDynamic[inlineDynamic]}`, () => {
|
||||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||||
[
|
[
|
||||||
textDef(['0', '1', '2']),
|
textDef(null, ['0', '1', '2']),
|
||||||
],
|
],
|
||||||
(view: ViewData) => {
|
(view: ViewData) => {
|
||||||
setCurrentNode(view, 0);
|
setCurrentNode(view, 0);
|
||||||
|
|
|
@ -17,8 +17,8 @@ export function main() {
|
||||||
|
|
||||||
it('should reverse child order for root nodes', () => {
|
it('should reverse child order for root nodes', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
textDef(['a']), // level 0, index 0
|
textDef(null, ['a']), // level 0, index 0
|
||||||
textDef(['a']), // level 0, index 0
|
textDef(null, ['a']), // level 0, index 0
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(reverseChildOrder(vd)).toEqual([1, 0]);
|
expect(reverseChildOrder(vd)).toEqual([1, 0]);
|
||||||
|
@ -26,9 +26,9 @@ export function main() {
|
||||||
|
|
||||||
it('should reverse child order for one level, one root', () => {
|
it('should reverse child order for one level, one root', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'), // level 0, index 0
|
elementDef(NodeFlags.None, null, null, 2, 'span'), // level 0, index 0
|
||||||
textDef(['a']), // level 1, index 1
|
textDef(null, ['a']), // level 1, index 1
|
||||||
textDef(['a']), // level 1, index 2
|
textDef(null, ['a']), // level 1, index 2
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(reverseChildOrder(vd)).toEqual([0, 2, 1]);
|
expect(reverseChildOrder(vd)).toEqual([0, 2, 1]);
|
||||||
|
@ -36,11 +36,11 @@ export function main() {
|
||||||
|
|
||||||
it('should reverse child order for 1 level, 2 roots', () => {
|
it('should reverse child order for 1 level, 2 roots', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'), // level 0, index 0
|
elementDef(NodeFlags.None, null, null, 2, 'span'), // level 0, index 0
|
||||||
textDef(['a']), // level 1, index 1
|
textDef(null, ['a']), // level 1, index 1
|
||||||
textDef(['a']), // level 1, index 2
|
textDef(null, ['a']), // level 1, index 2
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'), // level 0, index 3
|
elementDef(NodeFlags.None, null, null, 1, 'span'), // level 0, index 3
|
||||||
textDef(['a']), // level 1, index 4
|
textDef(null, ['a']), // level 1, index 4
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(reverseChildOrder(vd)).toEqual([3, 4, 0, 2, 1]);
|
expect(reverseChildOrder(vd)).toEqual([3, 4, 0, 2, 1]);
|
||||||
|
@ -48,11 +48,11 @@ export function main() {
|
||||||
|
|
||||||
it('should reverse child order for 2 levels', () => {
|
it('should reverse child order for 2 levels', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 4, 'span'), // level 0, index 0
|
elementDef(NodeFlags.None, null, null, 4, 'span'), // level 0, index 0
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'), // level 1, index 1
|
elementDef(NodeFlags.None, null, null, 1, 'span'), // level 1, index 1
|
||||||
textDef(['a']), // level 2, index 2
|
textDef(null, ['a']), // level 2, index 2
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'), // level 1, index 3
|
elementDef(NodeFlags.None, null, null, 1, 'span'), // level 1, index 3
|
||||||
textDef(['a']), // level 2, index 4
|
textDef(null, ['a']), // level 2, index 4
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(reverseChildOrder(vd)).toEqual([0, 3, 4, 1, 2]);
|
expect(reverseChildOrder(vd)).toEqual([0, 3, 4, 1, 2]);
|
||||||
|
@ -60,14 +60,14 @@ export function main() {
|
||||||
|
|
||||||
it('should reverse child order for mixed levels', () => {
|
it('should reverse child order for mixed levels', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
textDef(['a']), // level 0, index 0
|
textDef(null, ['a']), // level 0, index 0
|
||||||
elementDef(NodeFlags.None, null, 5, 'span'), // level 0, index 1
|
elementDef(NodeFlags.None, null, null, 5, 'span'), // level 0, index 1
|
||||||
textDef(['a']), // level 1, index 2
|
textDef(null, ['a']), // level 1, index 2
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'), // level 1, index 3
|
elementDef(NodeFlags.None, null, null, 1, 'span'), // level 1, index 3
|
||||||
textDef(['a']), // level 2, index 4
|
textDef(null, ['a']), // level 2, index 4
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'), // level 1, index 5
|
elementDef(NodeFlags.None, null, null, 1, 'span'), // level 1, index 5
|
||||||
textDef(['a']), // level 2, index 6
|
textDef(null, ['a']), // level 2, index 6
|
||||||
textDef(['a']), // level 0, index 7
|
textDef(null, ['a']), // level 0, index 7
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(reverseChildOrder(vd)).toEqual([7, 1, 5, 6, 3, 4, 2, 0]);
|
expect(reverseChildOrder(vd)).toEqual([7, 1, 5, 6, 3, 4, 2, 0]);
|
||||||
|
@ -81,9 +81,9 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate parents for one level', () => {
|
it('should calculate parents for one level', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
textDef(['a']),
|
textDef(null, ['a']),
|
||||||
textDef(['a']),
|
textDef(null, ['a']),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(parents(vd)).toEqual([undefined, 0, 0]);
|
expect(parents(vd)).toEqual([undefined, 0, 0]);
|
||||||
|
@ -91,11 +91,11 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate parents for one level, multiple roots', () => {
|
it('should calculate parents for one level, multiple roots', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
textDef(['a']),
|
textDef(null, ['a']),
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
textDef(['a']),
|
textDef(null, ['a']),
|
||||||
textDef(['a']),
|
textDef(null, ['a']),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(parents(vd)).toEqual([undefined, 0, undefined, 2, undefined]);
|
expect(parents(vd)).toEqual([undefined, 0, undefined, 2, undefined]);
|
||||||
|
@ -103,12 +103,12 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate parents for multiple levels', () => {
|
it('should calculate parents for multiple levels', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
textDef(['a']),
|
textDef(null, ['a']),
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
textDef(['a']),
|
textDef(null, ['a']),
|
||||||
textDef(['a']),
|
textDef(null, ['a']),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(parents(vd)).toEqual([undefined, 0, 1, undefined, 3, undefined]);
|
expect(parents(vd)).toEqual([undefined, 0, 1, undefined, 3, undefined]);
|
||||||
|
@ -123,7 +123,7 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate childFlags for one level', () => {
|
it('should calculate childFlags for one level', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.AfterContentChecked, null, 0, AService, [])
|
providerDef(NodeFlags.AfterContentChecked, null, 0, AService, [])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -132,7 +132,8 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate childFlags for two levels', () => {
|
it('should calculate childFlags for two levels', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'), elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.AfterContentChecked, null, 0, AService, [])
|
providerDef(NodeFlags.AfterContentChecked, null, 0, AService, [])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -143,9 +144,9 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate childFlags for one level, multiple roots', () => {
|
it('should calculate childFlags for one level, multiple roots', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.AfterContentChecked, null, 0, AService, []),
|
providerDef(NodeFlags.AfterContentChecked, null, 0, AService, []),
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
providerDef(NodeFlags.AfterContentInit, null, 0, AService, []),
|
providerDef(NodeFlags.AfterContentInit, null, 0, AService, []),
|
||||||
providerDef(NodeFlags.AfterViewChecked, null, 0, AService, []),
|
providerDef(NodeFlags.AfterViewChecked, null, 0, AService, []),
|
||||||
]);
|
]);
|
||||||
|
@ -158,10 +159,10 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate childFlags for multiple levels', () => {
|
it('should calculate childFlags for multiple levels', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.AfterContentChecked, null, 0, AService, []),
|
providerDef(NodeFlags.AfterContentChecked, null, 0, AService, []),
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
providerDef(NodeFlags.AfterContentInit, null, 0, AService, []),
|
providerDef(NodeFlags.AfterContentInit, null, 0, AService, []),
|
||||||
providerDef(NodeFlags.AfterViewInit, null, 0, AService, []),
|
providerDef(NodeFlags.AfterViewInit, null, 0, AService, []),
|
||||||
]);
|
]);
|
||||||
|
@ -180,7 +181,7 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate childMatchedQueries for one level', () => {
|
it('should calculate childMatchedQueries for one level', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 0, AService, [])
|
providerDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 0, AService, [])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -189,7 +190,8 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate childMatchedQueries for two levels', () => {
|
it('should calculate childMatchedQueries for two levels', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'), elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 0, AService, [])
|
providerDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 0, AService, [])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -198,9 +200,9 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate childMatchedQueries for one level, multiple roots', () => {
|
it('should calculate childMatchedQueries for one level, multiple roots', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 0, AService, []),
|
providerDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 0, AService, []),
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
providerDef(NodeFlags.None, [['q2', QueryValueType.Provider]], 0, AService, []),
|
providerDef(NodeFlags.None, [['q2', QueryValueType.Provider]], 0, AService, []),
|
||||||
providerDef(NodeFlags.None, [['q3', QueryValueType.Provider]], 0, AService, []),
|
providerDef(NodeFlags.None, [['q3', QueryValueType.Provider]], 0, AService, []),
|
||||||
]);
|
]);
|
||||||
|
@ -210,10 +212,10 @@ export function main() {
|
||||||
|
|
||||||
it('should calculate childMatchedQueries for multiple levels', () => {
|
it('should calculate childMatchedQueries for multiple levels', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
providerDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 0, AService, []),
|
providerDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 0, AService, []),
|
||||||
elementDef(NodeFlags.None, null, 2, 'span'),
|
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||||
providerDef(NodeFlags.None, [['q2', QueryValueType.Provider]], 0, AService, []),
|
providerDef(NodeFlags.None, [['q2', QueryValueType.Provider]], 0, AService, []),
|
||||||
providerDef(NodeFlags.None, [['q3', QueryValueType.Provider]], 0, AService, []),
|
providerDef(NodeFlags.None, [['q3', QueryValueType.Provider]], 0, AService, []),
|
||||||
]);
|
]);
|
||||||
|
@ -223,13 +225,13 @@ export function main() {
|
||||||
|
|
||||||
it('should included embedded views into childMatchedQueries', () => {
|
it('should included embedded views into childMatchedQueries', () => {
|
||||||
const vd = viewDef(ViewFlags.None, [
|
const vd = viewDef(ViewFlags.None, [
|
||||||
elementDef(NodeFlags.None, null, 1, 'span'),
|
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||||
anchorDef(
|
anchorDef(
|
||||||
NodeFlags.None, null, 0,
|
NodeFlags.None, null, null, 0,
|
||||||
viewDef(
|
viewDef(
|
||||||
ViewFlags.None,
|
ViewFlags.None,
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 1, 'span'),
|
elementDef(NodeFlags.None, [['q1', QueryValueType.Provider]], null, 1, 'span'),
|
||||||
]))
|
]))
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ let viewFlags = ViewFlags.DirectDom;
|
||||||
|
|
||||||
function TreeComponent_Host(): ViewDefinition {
|
function TreeComponent_Host(): ViewDefinition {
|
||||||
return viewDef(viewFlags, [
|
return viewDef(viewFlags, [
|
||||||
elementDef(NodeFlags.None, null, 1, 'tree'),
|
elementDef(NodeFlags.None, null, null, 1, 'tree'),
|
||||||
providerDef(NodeFlags.None, null, 0, TreeComponent, [], null, null, TreeComponent_0),
|
providerDef(NodeFlags.None, null, 0, TreeComponent, [], null, null, TreeComponent_0),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ function TreeComponent_0(): ViewDefinition {
|
||||||
const TreeComponent_1: ViewDefinition = viewDef(
|
const TreeComponent_1: ViewDefinition = viewDef(
|
||||||
viewFlags,
|
viewFlags,
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 1, 'tree'),
|
elementDef(NodeFlags.None, null, null, 1, 'tree'),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, TreeComponent, [], {data: [0, 'data']}, null, TreeComponent_0),
|
NodeFlags.None, null, 0, TreeComponent, [], {data: [0, 'data']}, null, TreeComponent_0),
|
||||||
],
|
],
|
||||||
|
@ -47,7 +47,7 @@ function TreeComponent_0(): ViewDefinition {
|
||||||
const TreeComponent_2: ViewDefinition = viewDef(
|
const TreeComponent_2: ViewDefinition = viewDef(
|
||||||
viewFlags,
|
viewFlags,
|
||||||
[
|
[
|
||||||
elementDef(NodeFlags.None, null, 1, 'tree'),
|
elementDef(NodeFlags.None, null, null, 1, 'tree'),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, TreeComponent, [], {data: [0, 'data']}, null, TreeComponent_0),
|
NodeFlags.None, null, 0, TreeComponent, [], {data: [0, 'data']}, null, TreeComponent_0),
|
||||||
],
|
],
|
||||||
|
@ -61,13 +61,13 @@ function TreeComponent_0(): ViewDefinition {
|
||||||
viewFlags,
|
viewFlags,
|
||||||
[
|
[
|
||||||
elementDef(
|
elementDef(
|
||||||
NodeFlags.None, null, 1, 'span', null,
|
NodeFlags.None, null, null, 1, 'span', null,
|
||||||
[[BindingType.ElementStyle, 'backgroundColor', null]]),
|
[[BindingType.ElementStyle, 'backgroundColor', null]]),
|
||||||
textDef([' ', ' ']),
|
textDef(null, [' ', ' ']),
|
||||||
anchorDef(NodeFlags.HasEmbeddedViews, null, 1, TreeComponent_1),
|
anchorDef(NodeFlags.HasEmbeddedViews, null, null, 1, TreeComponent_1),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, NgIf, [ViewContainerRef, TemplateRef], {ngIf: [0, 'ngIf']}),
|
NodeFlags.None, null, 0, NgIf, [ViewContainerRef, TemplateRef], {ngIf: [0, 'ngIf']}),
|
||||||
anchorDef(NodeFlags.HasEmbeddedViews, null, 1, TreeComponent_2),
|
anchorDef(NodeFlags.HasEmbeddedViews, null, null, 1, TreeComponent_2),
|
||||||
providerDef(
|
providerDef(
|
||||||
NodeFlags.None, null, 0, NgIf, [ViewContainerRef, TemplateRef], {ngIf: [0, 'ngIf']}),
|
NodeFlags.None, null, 0, NgIf, [ViewContainerRef, TemplateRef], {ngIf: [0, 'ngIf']}),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue