refactor(core): create consistent naming scheme across classes (#21403)

PR Close #21403
This commit is contained in:
Kara Erickson
2018-01-10 11:15:48 -08:00
parent 908129e9a2
commit fc3e7e0381
11 changed files with 369 additions and 385 deletions
+5 -5
View File
@@ -14,8 +14,8 @@ import {EmbeddedViewRef as viewEngine_EmbeddedViewRef} from '../linker/view_ref'
import {assertNotNull} from './assert';
import {ComponentDef, ComponentType} from './definition_interfaces';
import {NG_HOST_SYMBOL, createError, createViewState, directive, enterView, hostElement, leaveView, locateHostElement, renderComponentOrTemplate} from './instructions';
import {LElement} from './interfaces';
import {NG_HOST_SYMBOL, createError, createLView, directive, enterView, hostElement, leaveView, locateHostElement, renderComponentOrTemplate} from './instructions';
import {LElementNode} from './interfaces';
import {RElement, Renderer3, RendererFactory3, domRendererFactory3} from './renderer';
import {notImplemented, stringify} from './util';
@@ -170,7 +170,7 @@ export function renderComponent<T>(
let component: T;
const hostNode = locateHostElement(rendererFactory, opts.host || componentDef.tag);
const oldView = enterView(
createViewState(-1, rendererFactory.createRenderer(hostNode, componentDef.rendererType), []),
createLView(-1, rendererFactory.createRenderer(hostNode, componentDef.rendererType), []),
null !);
try {
// Create element node at index 0 in data array
@@ -188,7 +188,7 @@ export function renderComponent<T>(
export function detectChanges<T>(component: T) {
ngDevMode && assertNotNull(component, 'component');
const hostNode = (component as any)[NG_HOST_SYMBOL] as LElement;
const hostNode = (component as any)[NG_HOST_SYMBOL] as LElementNode;
if (ngDevMode && !hostNode) {
createError('Not a directive instance', component);
}
@@ -208,5 +208,5 @@ export function markDirty<T>(
}
export function getHostElement<T>(component: T): RElement {
return ((component as any)[NG_HOST_SYMBOL] as LElement).native;
return ((component as any)[NG_HOST_SYMBOL] as LElementNode).native;
}
+16 -16
View File
@@ -18,7 +18,7 @@ import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, ViewRef as viewEngine_Vie
import {Type} from '../type';
import {ComponentTemplate, DirectiveDef} from './definition_interfaces';
import {LContainer, LElement, LNodeFlags, LNodeInjector} from './interfaces';
import {LContainerNode, LElementNode, LInjector, LNodeFlags} from './interfaces';
import {assertNodeType} from './node_assert';
import {notImplemented, stringify} from './util';
@@ -48,7 +48,7 @@ let nextNgElementId = 0;
* @param injector The node injector in which the directive should be registered
* @param type The directive to register
*/
export function bloomAdd(injector: LNodeInjector, type: Type<any>): void {
export function bloomAdd(injector: LInjector, type: Type<any>): void {
let id: number|undefined = (type as any)[NG_ELEMENT_ID];
// Set a unique ID on the directive type, so if something tries to inject the directive,
@@ -92,7 +92,7 @@ export function bloomAdd(injector: LNodeInjector, type: Type<any>): void {
* @param node for which an injector should be retrieved / created.
* @returns Node injector
*/
export function getOrCreateNodeInjectorForNode(node: LElement | LContainer): LNodeInjector {
export function getOrCreateNodeInjectorForNode(node: LElementNode | LContainerNode): LInjector {
const nodeInjector = node.nodeInjector;
const parentInjector = node.parent && node.parent.nodeInjector;
if (nodeInjector != parentInjector) {
@@ -146,7 +146,7 @@ function createInjectionError(text: string, token: any) {
* @param di The node injector in which a directive will be added
* @param def The definition of the directive to be made public
*/
export function diPublicInInjector(di: LNodeInjector, def: DirectiveDef<any>): void {
export function diPublicInInjector(di: LInjector, def: DirectiveDef<any>): void {
bloomAdd(di, def.type);
}
@@ -167,8 +167,7 @@ export function diPublicInInjector(di: LNodeInjector, def: DirectiveDef<any>): v
* @param flags Injection flags (e.g. CheckParent)
* @returns The instance found
*/
export function getOrCreateInjectable<T>(
di: LNodeInjector, token: Type<T>, flags?: InjectFlags): T {
export function getOrCreateInjectable<T>(di: LInjector, token: Type<T>, flags?: InjectFlags): T {
const bloomHash = bloomHashBit(token);
// If the token has a bloom hash, then it is a directive that is public to the injection system
@@ -180,7 +179,7 @@ export function getOrCreateInjectable<T>(
}
moduleInjector.get(token);
} else {
let injector: LNodeInjector|null = di;
let injector: LInjector|null = di;
while (injector) {
// Get the closest potential matching injector (upwards in the injector tree) that
@@ -265,8 +264,8 @@ function bloomHashBit(type: Type<any>): number|null {
* @param bloomBit The bit to check in each injector's bloom filter
* @returns An injector that might have the directive
*/
export function bloomFindPossibleInjector(
startInjector: LNodeInjector, bloomBit: number): LNodeInjector|null {
export function bloomFindPossibleInjector(startInjector: LInjector, bloomBit: number): LInjector|
null {
// Create a mask that targets the specific bit associated with the directive we're looking for.
// JS bit operations are 32 bits, so this will be a number between 2^0 and 2^31, corresponding
// to bit positions 0 - 31 in a 32 bit integer.
@@ -274,7 +273,7 @@ export function bloomFindPossibleInjector(
// Traverse up the injector tree until we find a potential match or until we know there *isn't* a
// match.
let injector: LNodeInjector|null = startInjector;
let injector: LInjector|null = startInjector;
while (injector) {
// Our bloom filter size is 128 bits, which is four 32-bit bloom filter buckets:
// bf0 = [0 - 31], bf1 = [32 - 63], bf2 = [64 - 95], bf3 = [96 - 127]
@@ -307,7 +306,7 @@ export function bloomFindPossibleInjector(
* @param di The node injector where we should store a created ElementRef
* @returns The ElementRef instance to use
*/
export function getOrCreateElementRef(di: LNodeInjector): viewEngine_ElementRef {
export function getOrCreateElementRef(di: LInjector): viewEngine_ElementRef {
return di.elementRef || (di.elementRef = new ElementRef(di.node.native));
}
@@ -324,9 +323,9 @@ class ElementRef implements viewEngine_ElementRef {
* @param di The node injector where we should store a created TemplateRef
* @returns The TemplateRef instance to use
*/
export function getOrCreateTemplateRef<T>(di: LNodeInjector): viewEngine_TemplateRef<T> {
export function getOrCreateTemplateRef<T>(di: LInjector): viewEngine_TemplateRef<T> {
ngDevMode && assertNodeType(di.node, LNodeFlags.Container);
const data = (di.node as LContainer).data;
const data = (di.node as LContainerNode).data;
return di.templateRef ||
(di.templateRef = new TemplateRef<any>(getOrCreateElementRef(di), data.template));
}
@@ -348,8 +347,9 @@ class TemplateRef<T> implements viewEngine_TemplateRef<T> {
*
* @returns The ViewContainerRef instance to use
*/
export function getOrCreateContainerRef(di: LNodeInjector): viewEngine_ViewContainerRef {
return di.viewContainerRef || (di.viewContainerRef = new ViewContainerRef(di.node as LContainer));
export function getOrCreateContainerRef(di: LInjector): viewEngine_ViewContainerRef {
return di.viewContainerRef ||
(di.viewContainerRef = new ViewContainerRef(di.node as LContainerNode));
}
/**
@@ -361,7 +361,7 @@ class ViewContainerRef implements viewEngine_ViewContainerRef {
injector: Injector;
parentInjector: Injector;
constructor(node: LContainer) {}
constructor(node: LContainerNode) {}
clear(): void { throw notImplemented(); }
get(index: number): viewEngine_ViewRef|null { throw notImplemented(); }
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+62 -61
View File
@@ -7,7 +7,7 @@
*/
import {assertNotNull} from './assert';
import {ContainerState, LContainer, LElement, LNode, LNodeFlags, LProjection, LText, LView, ProjectionState, ViewOrContainerState, ViewState} from './interfaces';
import {LContainer, LContainerNode, LElementNode, LNode, LNodeFlags, LProjection, LProjectionNode, LTextNode, LView, LViewNode, LViewOrLContainer} from './interfaces';
import {assertNodeType} from './node_assert';
import {ProceduralRenderer3, RComment, RElement, RNode, RText} from './renderer';
@@ -22,15 +22,15 @@ import {ProceduralRenderer3, RComment, RElement, RNode, RText} from './renderer'
* @param containerNode The container node whose parent must be found
* @returns Closest DOM node above the container
*/
export function findNativeParent(containerNode: LContainer): RNode|null {
let container: LContainer|null = containerNode;
export function findNativeParent(containerNode: LContainerNode): RNode|null {
let container: LContainerNode|null = containerNode;
while (container) {
ngDevMode && assertNodeType(container, LNodeFlags.Container);
const renderParent = container.data.renderParent;
if (renderParent !== null) {
return renderParent.native;
}
const viewOrElement: LView|LElement = container.parent !;
const viewOrElement: LViewNode|LElementNode = container.parent !;
ngDevMode && assertNotNull(viewOrElement, 'container.parent');
if ((viewOrElement.flags & LNodeFlags.TYPE_MASK) === LNodeFlags.Element) {
// we are an LElement, which means we are past the last LContainer.
@@ -38,7 +38,7 @@ export function findNativeParent(containerNode: LContainer): RNode|null {
return null;
}
ngDevMode && assertNodeType(viewOrElement, LNodeFlags.View);
container = (viewOrElement as LView).parent;
container = (viewOrElement as LViewNode).parent;
}
return null;
}
@@ -52,15 +52,15 @@ export function findNativeParent(containerNode: LContainer): RNode|null {
* anchor is the marker.
*
* @param index The index of the view to check
* @param state ContainerState of the parent container
* @param lContainer parent LContainer
* @param native Comment anchor for container
* @returns The DOM element for which the view should insert elements
*/
function findBeforeNode(index: number, state: ContainerState, native: RNode): RNode {
const views = state.views;
function findBeforeNode(index: number, lContainer: LContainer, native: RNode): RNode {
const views = lContainer.views;
// Find the node to insert in front of
return index + 1 < views.length ?
(views[index + 1].child as LText | LElement | LContainer).native :
(views[index + 1].child as LTextNode | LElementNode | LContainerNode).native :
native;
}
@@ -77,11 +77,13 @@ function findBeforeNode(index: number, state: ContainerState, native: RNode): RN
* @param beforeNode The node before which elements should be added, if insert mode
*/
export function addRemoveViewFromContainer(
container: LContainer, rootNode: LView, insertMode: true, beforeNode: RNode | null): void;
container: LContainerNode, rootNode: LViewNode, insertMode: true,
beforeNode: RNode | null): void;
export function addRemoveViewFromContainer(
container: LContainer, rootNode: LView, insertMode: false): void;
container: LContainerNode, rootNode: LViewNode, insertMode: false): void;
export function addRemoveViewFromContainer(
container: LContainer, rootNode: LView, insertMode: boolean, beforeNode?: RNode | null): void {
container: LContainerNode, rootNode: LViewNode, insertMode: boolean,
beforeNode?: RNode | null): void {
ngDevMode && assertNodeType(container, LNodeFlags.Container);
ngDevMode && assertNodeType(rootNode, LNodeFlags.View);
const parent = findNativeParent(container);
@@ -105,7 +107,7 @@ export function addRemoveViewFromContainer(
} else if (type === LNodeFlags.Container) {
// if we get to a container, it must be a root node of a view because we are only
// propagating down into child views / containers and not child elements
const childContainerData: ContainerState = (node as LContainer).data;
const childContainerData: LContainer = (node as LContainerNode).data;
insertMode ? (isFnRenderer ?
(renderer as ProceduralRenderer3)
.appendChild !(parent as RElement, node.native !) :
@@ -116,9 +118,9 @@ export function addRemoveViewFromContainer(
parent.removeChild(node.native !));
nextNode = childContainerData.views.length ? childContainerData.views[0].child : null;
} else if (type === LNodeFlags.Projection) {
nextNode = (node as LProjection).data[0];
nextNode = (node as LProjectionNode).data[0];
} else {
nextNode = (node as LView).child;
nextNode = (node as LViewNode).child;
}
if (nextNode === null) {
while (node && !node.next) {
@@ -146,31 +148,31 @@ export function addRemoveViewFromContainer(
*
* @param rootView The view to destroy
*/
export function destroyViewTree(rootView: ViewState): void {
let viewOrContainerState: ViewOrContainerState|null = rootView;
export function destroyViewTree(rootView: LView): void {
let viewOrContainer: LViewOrLContainer|null = rootView;
while (viewOrContainerState) {
let next: ViewOrContainerState|null = null;
while (viewOrContainer) {
let next: LViewOrLContainer|null = null;
if (viewOrContainerState.views && viewOrContainerState.views.length) {
next = viewOrContainerState.views[0].data;
} else if (viewOrContainerState.child) {
next = viewOrContainerState.child;
} else if (viewOrContainerState.next) {
cleanUpView(viewOrContainerState as ViewState);
next = viewOrContainerState.next;
if (viewOrContainer.views && viewOrContainer.views.length) {
next = viewOrContainer.views[0].data;
} else if (viewOrContainer.child) {
next = viewOrContainer.child;
} else if (viewOrContainer.next) {
cleanUpView(viewOrContainer as LView);
next = viewOrContainer.next;
}
if (next == null) {
while (viewOrContainerState && !viewOrContainerState !.next) {
cleanUpView(viewOrContainerState as ViewState);
viewOrContainerState = getParentState(viewOrContainerState, rootView);
while (viewOrContainer && !viewOrContainer !.next) {
cleanUpView(viewOrContainer as LView);
viewOrContainer = getParentState(viewOrContainer, rootView);
}
cleanUpView(viewOrContainerState as ViewState || rootView);
cleanUpView(viewOrContainer as LView || rootView);
next = viewOrContainerState && viewOrContainerState.next;
next = viewOrContainer && viewOrContainer.next;
}
viewOrContainerState = next;
viewOrContainer = next;
}
}
@@ -187,7 +189,8 @@ export function destroyViewTree(rootView: ViewState): void {
* @param index The index at which to insert the view
* @returns The inserted view
*/
export function insertView(container: LContainer, newView: LView, index: number): LView {
export function insertView(
container: LContainerNode, newView: LViewNode, index: number): LViewNode {
const state = container.data;
const views = state.views;
@@ -232,7 +235,7 @@ export function insertView(container: LContainer, newView: LView, index: number)
* @param removeIndex The index of the view to remove
* @returns The removed view
*/
export function removeView(container: LContainer, removeIndex: number): LView {
export function removeView(container: LContainerNode, removeIndex: number): LViewNode {
const views = container.data.views;
const viewNode = views[removeIndex];
if (removeIndex > 0) {
@@ -248,34 +251,32 @@ export function removeView(container: LContainer, removeIndex: number): LView {
/**
* Sets a next on the view node, so views in for loops can easily jump from
* one view to the next to add/remove elements. Also adds the ViewState (view.data)
* one view to the next to add/remove elements. Also adds the LView (view.data)
* to the view tree for easy traversal when cleaning up the view.
*
* @param view The view to set up
* @param next The view's new next
*/
export function setViewNext(view: LView, next: LView | null): void {
export function setViewNext(view: LViewNode, next: LViewNode | null): void {
view.next = next;
view.data.next = next ? next.data : null;
}
/**
* Determines which ViewOrContainerState to jump to when traversing back up the
* Determines which LViewOrLContainer to jump to when traversing back up the
* tree in destroyViewTree.
*
* Normally, the view's parent ViewState should be checked, but in the case of
* Normally, the view's parent LView should be checked, but in the case of
* embedded views, the container (which is the view node's parent, but not the
* ViewState's parent) needs to be checked for a possible next property.
* LView's parent) needs to be checked for a possible next property.
*
* @param state The ViewOrContainerState for which we need a parent state
* @param state The LViewOrLContainer for which we need a parent state
* @param rootView The rootView, so we don't propagate too far up the view tree
* @returns The correct parent ViewOrContainerState
* @returns The correct parent LViewOrLContainer
*/
export function getParentState(
state: ViewOrContainerState, rootView: ViewState): ViewOrContainerState|null {
export function getParentState(state: LViewOrLContainer, rootView: LView): LViewOrLContainer|null {
let node;
if ((node = (state as ViewState) !.node) &&
(node.flags & LNodeFlags.TYPE_MASK) === LNodeFlags.View) {
if ((node = (state as LView) !.node) && (node.flags & LNodeFlags.TYPE_MASK) === LNodeFlags.View) {
// if it's an embedded view, the state needs to go up to the container, in case the
// container has a next
return node.parent !.data as any;
@@ -288,11 +289,11 @@ export function getParentState(
/**
* Removes all listeners and call all onDestroys in a given view.
*
* @param viewState The ViewState of the view to clean up
* @param view The LView to clean up
*/
function cleanUpView(viewState: ViewState): void {
if (!viewState.cleanup) return;
const cleanup = viewState.cleanup !;
function cleanUpView(view: LView): void {
if (!view.cleanup) return;
const cleanup = view.cleanup !;
for (let i = 0; i < cleanup.length - 1; i += 2) {
if (typeof cleanup[i] === 'string') {
cleanup ![i + 1].removeEventListener(cleanup[i], cleanup[i + 2], cleanup[i + 3]);
@@ -301,7 +302,7 @@ function cleanUpView(viewState: ViewState): void {
cleanup[i].call(cleanup[i + 1]);
}
}
viewState.cleanup = null;
view.cleanup = null;
}
/**
@@ -314,10 +315,10 @@ function cleanUpView(viewState: ViewState): void {
*
* @param parent The parent to which to append the child
* @param child The child that should be appended
* @param currentView The current view's ViewState
* @param currentView The current LView
* @returns Whether or not the child was appended
*/
export function appendChild(parent: LNode, child: RNode | null, currentView: ViewState): boolean {
export function appendChild(parent: LNode, child: RNode | null, currentView: LView): boolean {
// Only add native child element to parent element if the parent element is regular Element.
// If parent is:
// - Regular element => add child
@@ -350,9 +351,9 @@ export function appendChild(parent: LNode, child: RNode | null, currentView: Vie
* the content projection system. Otherwise, insertBefore normally.
*
* @param node Node to insert
* @param currentView The current view's ViewState
* @param currentView Current LView
*/
export function insertChild(node: LNode, currentView: ViewState): void {
export function insertChild(node: LNode, currentView: LView): void {
const parent = node.parent !;
// Only add child element to parent element if the parent element is regular Element.
// If parent is:
@@ -389,11 +390,11 @@ export function insertChild(node: LNode, currentView: ViewState): void {
* @param projectedNodes Array to store the projected node
* @param node The node to process
* @param currentParent The last parent element to be processed
* @param currentView The current view's ViewState
* @param currentView Current LView
*/
export function processProjectedNode(
projectedNodes: ProjectionState, node: LElement | LText | LContainer,
currentParent: LView | LElement, currentView: ViewState): void {
projectedNodes: LProjection, node: LElementNode | LTextNode | LContainerNode,
currentParent: LViewNode | LElementNode, currentView: LView): void {
if ((node.flags & LNodeFlags.TYPE_MASK) === LNodeFlags.Container &&
(currentParent.flags & LNodeFlags.TYPE_MASK) === LNodeFlags.Element &&
(currentParent.data === null || currentParent.data === currentView)) {
@@ -402,11 +403,11 @@ export function processProjectedNode(
// Alternatively a container is projected at the root of a component's template
// and can't be re-projected (as not content of any component).
// Assignee the final projection location in those cases.
const containerState = (node as LContainer).data;
containerState.renderParent = currentParent as LElement;
const views = containerState.views;
const lContainer = (node as LContainerNode).data;
lContainer.renderParent = currentParent as LElementNode;
const views = lContainer.views;
for (let i = 0; i < views.length; i++) {
addRemoveViewFromContainer(node as LContainer, views[i], true, null);
addRemoveViewFromContainer(node as LContainerNode, views[i], true, null);
}
}
projectedNodes.push(node);
@@ -10,7 +10,7 @@ import './ng_dev_mode';
import {assertNotNull} from './assert';
import {CssSelector, CssSelectorWithNegations, SimpleCssSelector} from './interfaces';
import {LNodeStatic} from './l_node_static';
import {TNode} from './t_node';
function isCssClassMatching(nodeClassAttrVal: string, cssClassToMatch: string): boolean {
const nodeClassesLen = nodeClassAttrVal.length;
@@ -33,14 +33,13 @@ function isCssClassMatching(nodeClassAttrVal: string, cssClassToMatch: string):
* @param selector
* @returns true if node matches the selector.
*/
export function isNodeMatchingSimpleSelector(
lNodeStaticData: LNodeStatic, selector: SimpleCssSelector): boolean {
export function isNodeMatchingSimpleSelector(tNode: TNode, selector: SimpleCssSelector): boolean {
const noOfSelectorParts = selector.length;
ngDevMode && assertNotNull(selector[0], 'selector[0]');
const tagNameInSelector = selector[0];
// check tag tame
if (tagNameInSelector !== '' && tagNameInSelector !== lNodeStaticData.tagName) {
if (tagNameInSelector !== '' && tagNameInSelector !== tNode.tagName) {
return false;
}
@@ -50,11 +49,11 @@ export function isNodeMatchingSimpleSelector(
}
// short-circuit case where an element has no attrs but a selector tries to match some
if (noOfSelectorParts > 1 && !lNodeStaticData.attrs) {
if (noOfSelectorParts > 1 && !tNode.attrs) {
return false;
}
const attrsInNode = lNodeStaticData.attrs !;
const attrsInNode = tNode.attrs !;
for (let i = 1; i < noOfSelectorParts; i += 2) {
const attrNameInSelector = selector[i];
@@ -84,10 +83,9 @@ export function isNodeMatchingSimpleSelector(
}
export function isNodeMatchingSelectorWithNegations(
lNodeStaticData: LNodeStatic, selector: CssSelectorWithNegations): boolean {
tNode: TNode, selector: CssSelectorWithNegations): boolean {
const positiveSelector = selector[0];
if (positiveSelector != null &&
!isNodeMatchingSimpleSelector(lNodeStaticData, positiveSelector)) {
if (positiveSelector != null && !isNodeMatchingSimpleSelector(tNode, positiveSelector)) {
return false;
}
@@ -96,7 +94,7 @@ export function isNodeMatchingSelectorWithNegations(
if (negativeSelectors) {
for (let i = 0; i < negativeSelectors.length; i++) {
// if one of negative selectors matched than the whole selector doesn't match
if (isNodeMatchingSimpleSelector(lNodeStaticData, negativeSelectors[i])) {
if (isNodeMatchingSimpleSelector(tNode, negativeSelectors[i])) {
return false;
}
}
@@ -105,10 +103,9 @@ export function isNodeMatchingSelectorWithNegations(
return true;
}
export function isNodeMatchingSelector(
lNodeStaticData: LNodeStatic, selector: CssSelector): boolean {
export function isNodeMatchingSelector(tNode: TNode, selector: CssSelector): boolean {
for (let i = 0; i < selector.length; i++) {
if (isNodeMatchingSelectorWithNegations(lNodeStaticData, selector[i])) {
if (isNodeMatchingSelectorWithNegations(tNode, selector[i])) {
return true;
}
}
+19 -17
View File
@@ -18,9 +18,11 @@ import {Type} from '../type';
import {assertNotNull} from './assert';
import {DirectiveDef} from './definition_interfaces';
import {getOrCreateContainerRef, getOrCreateElementRef, getOrCreateNodeInjectorForNode, getOrCreateTemplateRef} from './di';
import {LContainer, LElement, LNode, LNodeFlags, LNodeInjector, LView, QueryReadType, QueryState} from './interfaces';
import {LNodeStatic} from './l_node_static';
import {LContainerNode, LElementNode, LInjector, LNode, LNodeFlags, LQuery, LViewNode, QueryReadType} from './interfaces';
import {assertNodeOfPossibleTypes} from './node_assert';
import {TNode} from './t_node';
/**
* A predicate which determines if a given element/directive should be included in the query
@@ -37,7 +39,7 @@ export interface QueryPredicate<T> {
list: QueryList<T>;
/**
* If looking for directives than it contains the directive type.
* If looking for directives then it contains the directive type.
*/
type: Type<T>|null;
@@ -59,7 +61,7 @@ export interface QueryPredicate<T> {
values: any[];
}
export class QueryState_ implements QueryState {
export class LQuery_ implements LQuery {
shallow: QueryPredicate<any>|null = null;
deep: QueryPredicate<any>|null = null;
@@ -78,9 +80,9 @@ export class QueryState_ implements QueryState {
}
}
child(): QueryState|null {
child(): LQuery|null {
if (this.deep === null) {
// if we don't have any deep queries than no need to track anything more.
// if we don't have any deep queries then no need to track anything more.
return null;
}
if (this.shallow === null) {
@@ -89,7 +91,7 @@ export class QueryState_ implements QueryState {
return this;
} else {
// We need to create new state
return new QueryState_(this.deep);
return new LQuery_(this.deep);
}
}
@@ -98,11 +100,11 @@ export class QueryState_ implements QueryState {
add(this.deep, node);
}
insertView(container: LContainer, view: LView, index: number): void {
insertView(container: LContainerNode, view: LViewNode, index: number): void {
throw new Error('Method not implemented.');
}
removeView(container: LContainer, view: LView, index: number): void {
removeView(container: LContainerNode, view: LViewNode, index: number): void {
throw new Error('Method not implemented.');
}
}
@@ -111,12 +113,12 @@ export class QueryState_ implements QueryState {
* Iterates over local names for a given node and returns directive index
* (or -1 if a local name points to an element).
*
* @param staticData static data of a node to check
* @param tNode static data of a node to check
* @param selector selector to match
* @returns directive index, -1 or null if a selector didn't match any of the local names
*/
function getIdxOfMatchingSelector(staticData: LNodeStatic, selector: string): number|null {
const localNames = staticData.localNames;
function getIdxOfMatchingSelector(tNode: TNode, selector: string): number|null {
const localNames = tNode.localNames;
if (localNames) {
for (let i = 0; i < localNames.length; i += 2) {
if (localNames[i] === selector) {
@@ -148,7 +150,7 @@ function geIdxOfMatchingDirective(node: LNode, type: Type<any>): number|null {
return null;
}
function readDefaultInjectable(nodeInjector: LNodeInjector, node: LNode): viewEngine_ElementRef|
function readDefaultInjectable(nodeInjector: LInjector, node: LNode): viewEngine_ElementRef|
viewEngine_TemplateRef<any>|undefined {
ngDevMode && assertNodeOfPossibleTypes(node, LNodeFlags.Container, LNodeFlags.Element);
if ((node.flags & LNodeFlags.TYPE_MASK) === LNodeFlags.Element) {
@@ -159,7 +161,7 @@ function readDefaultInjectable(nodeInjector: LNodeInjector, node: LNode): viewEn
}
function readFromNodeInjector(
nodeInjector: LNodeInjector, node: LNode, read: QueryReadType | Type<any>): any {
nodeInjector: LInjector, node: LNode, read: QueryReadType | Type<any>): any {
if (read === QueryReadType.ElementRef) {
return getOrCreateElementRef(nodeInjector);
} else if (read === QueryReadType.ViewContainerRef) {
@@ -176,7 +178,7 @@ function readFromNodeInjector(
}
function add(predicate: QueryPredicate<any>| null, node: LNode) {
const nodeInjector = getOrCreateNodeInjectorForNode(node as LElement | LContainer);
const nodeInjector = getOrCreateNodeInjectorForNode(node as LElementNode | LContainerNode);
while (predicate) {
const type = predicate.type;
if (type) {
@@ -194,8 +196,8 @@ function add(predicate: QueryPredicate<any>| null, node: LNode) {
} else {
const selector = predicate.selector !;
for (let i = 0; i < selector.length; i++) {
ngDevMode && assertNotNull(node.staticData, 'node.staticData');
const directiveIdx = getIdxOfMatchingSelector(node.staticData !, selector[i]);
ngDevMode && assertNotNull(node.tNode, 'node.tNode');
const directiveIdx = getIdxOfMatchingSelector(node.tNode !, selector[i]);
// is anything on a node matching a selector?
if (directiveIdx !== null) {
if (predicate.read !== null) {
@@ -9,7 +9,7 @@
import {DirectiveDef} from './definition_interfaces';
/** The type of the global ngStaticData array. */
export type NgStaticData = (LNodeStatic | DirectiveDef<any>| null)[];
export type NgStaticData = (TNode | DirectiveDef<any>| null)[];
/**
* LNode binding data (flyweight) for a particular node that is shared between all templates
@@ -22,7 +22,7 @@ export type NgStaticData = (LNodeStatic | DirectiveDef<any>| null)[];
*
* see: https://en.wikipedia.org/wiki/Flyweight_pattern for more on the Flyweight pattern
*/
export interface LNodeStatic {
export interface TNode {
/** The tag name associated with this node. */
tagName: string|null;
@@ -72,7 +72,7 @@ export interface LNodeStatic {
outputs: PropertyAliases|null|undefined;
/**
* If this LNodeStatic corresponds to an LContainer, the container will
* If this TNode corresponds to an LContainerNode, the container will
* need to have nested static data for each of its embedded views.
* Otherwise, nodes in embedded views with the same index as nodes
* in their parent views will overwrite each other, as they are in
@@ -86,14 +86,14 @@ export interface LNodeStatic {
* [{tagName: 'button', attrs ...}, null] // V(1) ngData
* ]
*/
containerStatic: (LNodeStatic|null)[][]|null;
containerStatic: (TNode|null)[][]|null;
}
/** Static data for an LElement */
export interface LElementStatic extends LNodeStatic { containerStatic: null; }
/** Static data for an LElementNode */
export interface TElementNode extends TNode { containerStatic: null; }
/** Static data for an LContainer */
export interface LContainerStatic extends LNodeStatic { containerStatic: (LNodeStatic|null)[][]; }
/** Static data for an LContainerNode */
export interface TContainerNode extends TNode { containerStatic: (TNode|null)[][]; }
/**
* This mapping is necessary so we can set input properties and output listeners
+4 -4
View File
@@ -10,8 +10,8 @@ import {ElementRef, TemplateRef, ViewContainerRef} from '@angular/core';
import {bloomAdd, bloomFindPossibleInjector} from '../../src/render3/di';
import {C, D, E, PublicFeature, T, V, b, b2, c, cR, cr, defineDirective, e, inject, injectElementRef, injectTemplateRef, injectViewContainerRef, t, v} from '../../src/render3/index';
import {createLNode, createViewState, enterView, getOrCreateNodeInjector, leaveView} from '../../src/render3/instructions';
import {LNodeFlags, LNodeInjector} from '../../src/render3/interfaces';
import {createLNode, createLView, enterView, getOrCreateNodeInjector, leaveView} from '../../src/render3/instructions';
import {LInjector, LNodeFlags} from '../../src/render3/interfaces';
import {renderToHtml} from './render_util';
@@ -213,7 +213,7 @@ describe('di', () => {
describe('inject', () => {
describe('bloom filter', () => {
let di: LNodeInjector;
let di: LInjector;
beforeEach(() => {
di = {} as any;
di.bf0 = 0;
@@ -318,7 +318,7 @@ describe('di', () => {
describe('getOrCreateNodeInjector', () => {
it('should handle initial undefined state', () => {
const contentView = createViewState(-1, null !, []);
const contentView = createLView(-1, null !, []);
const oldView = enterView(contentView, null !);
try {
const parent = createLNode(0, LNodeFlags.Element, null, null);
@@ -7,10 +7,10 @@
*/
import {CssSelector, CssSelectorWithNegations, SimpleCssSelector} from '../../src/render3/interfaces';
import {LNodeStatic} from '../../src/render3/l_node_static';
import {isNodeMatchingSelector, isNodeMatchingSelectorWithNegations, isNodeMatchingSimpleSelector} from '../../src/render3/node_selector_matcher';
import {TNode} from '../../src/render3/t_node';
function testLStaticData(tagName: string, attrs: string[] | null): LNodeStatic {
function testLStaticData(tagName: string, attrs: string[] | null): TNode {
return {
tagName,
attrs,
+4 -4
View File
@@ -8,14 +8,14 @@
import {stringifyElement} from '@angular/platform-browser/testing/src/browser_util';
import {ComponentTemplate, ComponentType, DirectiveType, PublicFeature, defineComponent, defineDirective, renderComponent as _renderComponent} from '../../src/render3/index';
import {NG_HOST_SYMBOL, createLNode, createViewState, renderTemplate} from '../../src/render3/instructions';
import {LElement, LNodeFlags} from '../../src/render3/interfaces';
import {NG_HOST_SYMBOL, createLNode, createLView, renderTemplate} from '../../src/render3/instructions';
import {LElementNode, LNodeFlags} from '../../src/render3/interfaces';
import {RElement, RText, Renderer3, RendererFactory3, domRendererFactory3} from '../../src/render3/renderer';
import {getRendererFactory2} from './imported_renderer2';
export const document = ((global || window) as any).document;
export let containerEl: HTMLElement = null !;
let host: LElement|null;
let host: LElementNode|null;
const isRenderer2 =
typeof process == 'object' && process.argv[3] && process.argv[3] === '--r=renderer2';
// tslint:disable-next-line:no-console
@@ -63,7 +63,7 @@ export function renderComponent<T>(type: ComponentType<T>, rendererFactory?: Ren
}
export function toHtml<T>(componentOrElement: T | RElement): string {
const node = (componentOrElement as any)[NG_HOST_SYMBOL] as LElement;
const node = (componentOrElement as any)[NG_HOST_SYMBOL] as LElementNode;
if (node) {
return toHtml(node.native);
} else {