build: reformat repo to new clang@1.4.0 (#36628)

PR Close #36628
This commit is contained in:
Joey Perrott
2020-04-13 17:43:52 -07:00
committed by atscott
parent 4b3f9ac739
commit 26f49151e7
1163 changed files with 31727 additions and 24036 deletions

View File

@ -20,9 +20,10 @@ import {LView, TVIEW, TView} from './interfaces/view';
export function assertTNodeForLView(tNode: TNode, lView: LView) {
tNode.hasOwnProperty('tView_') && assertEqual(
(tNode as any as{tView_: TView}).tView_, lView[TVIEW],
'This TNode does not belong to this LView.');
tNode.hasOwnProperty('tView_') &&
assertEqual(
(tNode as any as {tView_: TView}).tView_, lView[TVIEW],
'This TNode does not belong to this LView.');
}
export function assertComponentType(
@ -45,9 +46,9 @@ export function assertPreviousIsParent(isParent: boolean) {
assertEqual(isParent, true, 'previousOrParentTNode should be a parent');
}
export function assertHasParent(tNode: TNode | null) {
export function assertHasParent(tNode: TNode|null) {
assertDefined(tNode, 'previousOrParentTNode should exist!');
assertDefined(tNode !.parent, 'previousOrParentTNode should have a parent');
assertDefined(tNode!.parent, 'previousOrParentTNode should have a parent');
}
export function assertDataNext(lView: LView, index: number, arr?: any[]) {

View File

@ -12,15 +12,16 @@ import {Type} from '../core';
import {Injector} from '../di/injector';
import {Sanitizer} from '../sanitization/sanitizer';
import {assertDataInRange} from '../util/assert';
import {assertComponentType} from './assert';
import {getComponentDef} from './definition';
import {diPublicInInjector, getOrCreateNodeInjectorForNode} from './di';
import {registerPostOrderHooks} from './hooks';
import {CLEAN_PROMISE, addHostBindingsToExpandoInstructions, addToViewTree, createLView, createTView, getOrCreateTComponentView, getOrCreateTNode, growHostVarsSpace, initTNodeFlags, instantiateRootComponent, invokeHostBindingsInCreationMode, locateHostElement, markAsComponentHost, refreshView, renderView} from './instructions/shared';
import {addHostBindingsToExpandoInstructions, addToViewTree, CLEAN_PROMISE, createLView, createTView, getOrCreateTComponentView, getOrCreateTNode, growHostVarsSpace, initTNodeFlags, instantiateRootComponent, invokeHostBindingsInCreationMode, locateHostElement, markAsComponentHost, refreshView, renderView} from './instructions/shared';
import {ComponentDef, ComponentType, RenderFlags} from './interfaces/definition';
import {TElementNode, TNode, TNodeType} from './interfaces/node';
import {PlayerHandler} from './interfaces/player';
import {RElement, Renderer3, RendererFactory3, domRendererFactory3} from './interfaces/renderer';
import {domRendererFactory3, RElement, Renderer3, RendererFactory3} from './interfaces/renderer';
import {CONTEXT, HEADER_OFFSET, LView, LViewFlags, RootContext, RootContextFlags, TVIEW, TViewType} from './interfaces/view';
import {writeDirectClass, writeDirectStyle} from './node_manipulation';
import {enterView, getPreviousOrParentTNode, leaveView, setSelectedIndex} from './state';
@ -107,7 +108,7 @@ export const NULL_INJECTOR: Injector = {
*/
export function renderComponent<T>(
componentType: ComponentType<T>|
Type<T>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */
Type<T>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */
,
opts: CreateComponentOptions = {}): T {
ngDevMode && publishDefaultGlobalUtils();
@ -115,11 +116,11 @@ export function renderComponent<T>(
const rendererFactory = opts.rendererFactory || domRendererFactory3;
const sanitizer = opts.sanitizer || null;
const componentDef = getComponentDef<T>(componentType) !;
if (componentDef.type != componentType) (componentDef as{type: Type<any>}).type = componentType;
const componentDef = getComponentDef<T>(componentType)!;
if (componentDef.type != componentType) (componentDef as {type: Type<any>}).type = componentType;
// The first index of the first selector is the tag name.
const componentTag = componentDef.selectors ![0] ![0] as string;
const componentTag = componentDef.selectors![0]![0] as string;
const hostRenderer = rendererFactory.createRenderer(null, null);
const hostRNode =
locateHostElement(hostRenderer, opts.host || componentTag, componentDef.encapsulation);
@ -168,9 +169,8 @@ export function renderComponent<T>(
* @returns Component view created
*/
export function createRootComponentView(
rNode: RElement | null, def: ComponentDef<any>, rootView: LView,
rendererFactory: RendererFactory3, hostRenderer: Renderer3,
sanitizer?: Sanitizer | null): LView {
rNode: RElement|null, def: ComponentDef<any>, rootView: LView,
rendererFactory: RendererFactory3, hostRenderer: Renderer3, sanitizer?: Sanitizer|null): LView {
const tView = rootView[TVIEW];
ngDevMode && assertDataInRange(rootView, 0 + HEADER_OFFSET);
rootView[0 + HEADER_OFFSET] = rNode;
@ -213,7 +213,7 @@ export function createRootComponentView(
*/
export function createRootComponent<T>(
componentView: LView, componentDef: ComponentDef<T>, rootLView: LView, rootContext: RootContext,
hostFeatures: HostFeature[] | null): any {
hostFeatures: HostFeature[]|null): any {
const tView = rootLView[TVIEW];
// Create directive instance with factory() and store at next index in viewData
const component = instantiateRootComponent(tView, rootLView, componentDef);
@ -270,13 +270,13 @@ export function createRootContext(
* ```
*/
export function LifecycleHooksFeature(component: any, def: ComponentDef<any>): void {
const rootTView = readPatchedLView(component) ![TVIEW];
const rootTView = readPatchedLView(component)![TVIEW];
const dirIndex = rootTView.data.length - 1;
// TODO(misko): replace `as TNode` with createTNode call. (needs refactoring to lose dep on
// LNode).
registerPostOrderHooks(
rootTView, { directiveStart: dirIndex, directiveEnd: dirIndex + 1 } as TNode);
rootTView, {directiveStart: dirIndex, directiveEnd: dirIndex + 1} as TNode);
}
/**

View File

@ -21,13 +21,13 @@ import {VERSION} from '../version';
import {NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR} from '../view/provider';
import {assertComponentType} from './assert';
import {LifecycleHooksFeature, createRootComponent, createRootComponentView, createRootContext} from './component';
import {createRootComponent, createRootComponentView, createRootContext, LifecycleHooksFeature} from './component';
import {getComponentDef} from './definition';
import {NodeInjector} from './di';
import {assignTViewNodeToLView, createLView, createTView, elementCreate, locateHostElement, renderView} from './instructions/shared';
import {ComponentDef} from './interfaces/definition';
import {TContainerNode, TElementContainerNode, TElementNode} from './interfaces/node';
import {RNode, RendererFactory3, domRendererFactory3} from './interfaces/renderer';
import {domRendererFactory3, RendererFactory3, RNode} from './interfaces/renderer';
import {LView, LViewFlags, TVIEW, TViewType} from './interfaces/view';
import {MATH_ML_NAMESPACE, SVG_NAMESPACE} from './namespaces';
import {writeDirectClass} from './node_manipulation';
@ -43,11 +43,13 @@ export class ComponentFactoryResolver extends viewEngine_ComponentFactoryResolve
/**
* @param ngModule The NgModuleRef to which all resolved factories are bound.
*/
constructor(private ngModule?: viewEngine_NgModuleRef<any>) { super(); }
constructor(private ngModule?: viewEngine_NgModuleRef<any>) {
super();
}
resolveComponentFactory<T>(component: Type<T>): viewEngine_ComponentFactory<T> {
ngDevMode && assertComponentType(component);
const componentDef = getComponentDef(component) !;
const componentDef = getComponentDef(component)!;
return new ComponentFactory(componentDef, this.ngModule);
}
}
@ -79,7 +81,7 @@ export const SCHEDULER = new InjectionToken<((fn: () => void) => void)>('SCHEDUL
function createChainedInjector(rootViewInjector: Injector, moduleInjector: Injector): Injector {
return {
get: <T>(token: Type<T>| InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): T => {
get: <T>(token: Type<T>|InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): T => {
const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as T, flags);
if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
@ -205,8 +207,9 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
// projectable nodes can be passed as array of arrays or an array of iterables (ngUpgrade
// case). Here we do normalize passed data structure to be an array of arrays to avoid
// complex checks down the line.
tElementNode.projection =
projectableNodes.map((nodesforSlot: RNode[]) => { return Array.from(nodesforSlot); });
tElementNode.projection = projectableNodes.map((nodesforSlot: RNode[]) => {
return Array.from(nodesforSlot);
});
}
// TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
@ -227,7 +230,7 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
if (!rootSelectorOrNode || isIsolated) {
// The host element of the internal or isolated root view is attached to the component's host
// view node.
componentRef.hostView._tViewNode !.child = tElementNode;
componentRef.hostView._tViewNode!.child = tElementNode;
}
return componentRef;
}
@ -272,7 +275,9 @@ export class ComponentRef<T> extends viewEngine_ComponentRef<T> {
this.componentType = componentType;
}
get injector(): Injector { return new NodeInjector(this._tNode, this._rootLView); }
get injector(): Injector {
return new NodeInjector(this._tNode, this._rootLView);
}
destroy(): void {
if (this.destroyCbs) {

View File

@ -18,7 +18,8 @@ import {getComponentLViewByIndex, getNativeByTNodeOrNull, readPatchedData, unwra
/** Returns the matching `LContext` data for a given DOM node, directive or component instance.
/**
* Returns the matching `LContext` data for a given DOM node, directive or component instance.
*
* This function will examine the provided DOM element, component, or directive instance\'s
* monkey-patched property to derive the `LContext` data. Once called then the monkey-patched
@ -43,7 +44,7 @@ export function getLContext(target: any): LContext|null {
// only when it's an array is it considered an LView instance
// ... otherwise it's an already constructed LContext instance
if (Array.isArray(mpValue)) {
const lView: LView = mpValue !;
const lView: LView = mpValue!;
let nodeIndex: number;
let component: any = undefined;
let directives: any[]|null|undefined = undefined;
@ -173,7 +174,7 @@ export function getComponentViewByInstance(componentInstance: {}): LView {
* Assigns the given data to the given target (which could be a component,
* directive or DOM node instance) using monkey-patching.
*/
export function attachPatchData(target: any, data: LView | LContext) {
export function attachPatchData(target: any, data: LView|LContext) {
target[MONKEY_PATCH_KEY_NAME] = data;
}
@ -191,7 +192,7 @@ export function isDirectiveInstance(instance: any): boolean {
function findViaNativeElement(lView: LView, target: RElement): number {
let tNode = lView[TVIEW].firstChild;
while (tNode) {
const native = getNativeByTNodeOrNull(tNode, lView) !;
const native = getNativeByTNodeOrNull(tNode, lView)!;
if (native === target) {
return tNode.index;
}

View File

@ -303,7 +303,7 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
decls: componentDefinition.decls,
vars: componentDefinition.vars,
factory: null,
template: componentDefinition.template || null !,
template: componentDefinition.template || null!,
consts: componentDefinition.consts || null,
ngContentSelectors: componentDefinition.ngContentSelectors,
hostBindings: componentDefinition.hostBindings || null,
@ -311,8 +311,8 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
hostAttrs: componentDefinition.hostAttrs || null,
contentQueries: componentDefinition.contentQueries || null,
declaredInputs: declaredInputs,
inputs: null !, // assigned in noSideEffects
outputs: null !, // assigned in noSideEffects
inputs: null!, // assigned in noSideEffects
outputs: null!, // assigned in noSideEffects
exportAs: componentDefinition.exportAs || null,
onChanges: null,
onInit: typePrototype.ngOnInit || null,
@ -323,8 +323,8 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
afterViewChecked: typePrototype.ngAfterViewChecked || null,
onDestroy: typePrototype.ngOnDestroy || null,
onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
directiveDefs: null !, // assigned in noSideEffects
pipeDefs: null !, // assigned in noSideEffects
directiveDefs: null!, // assigned in noSideEffects
pipeDefs: null!, // assigned in noSideEffects
selectors: componentDefinition.selectors || EMPTY_ARRAY,
viewQuery: componentDefinition.viewQuery || null,
features: componentDefinition.features as DirectiveDefFeature[] || null,
@ -339,9 +339,9 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
schemas: componentDefinition.schemas || null,
tView: null,
};
const directiveTypes = componentDefinition.directives !;
const directiveTypes = componentDefinition.directives!;
const feature = componentDefinition.features;
const pipeTypes = componentDefinition.pipes !;
const pipeTypes = componentDefinition.pipes!;
def.id += _renderCompCount++;
def.inputs = invertObject(componentDefinition.inputs, declaredInputs),
def.outputs = invertObject(componentDefinition.outputs),
@ -373,7 +373,7 @@ export function extractDirectiveDef(type: Type<any>): DirectiveDef<any>|Componen
if (ngDevMode && !def) {
throw new Error(`'${type.name}' is neither 'ComponentType' or 'DirectiveType'.`);
}
return def !;
return def!;
}
export function extractPipeDef(type: Type<any>): PipeDef<any> {
@ -381,7 +381,7 @@ export function extractPipeDef(type: Type<any>): PipeDef<any> {
if (ngDevMode && !def) {
throw new Error(`'${type.name}' is not a 'PipeType'.`);
}
return def !;
return def!;
}
export const autoRegisterModuleById: {[id: string]: NgModuleType} = {};
@ -425,8 +425,9 @@ export function ɵɵdefineNgModule<T>(def: {
id: def.id || null,
};
if (def.id != null) {
noSideEffects(
() => { autoRegisterModuleById[def.id !] = def.type as unknown as NgModuleType; });
noSideEffects(() => {
autoRegisterModuleById[def.id!] = def.type as unknown as NgModuleType;
});
}
return res as never;
}
@ -443,7 +444,7 @@ export function ɵɵdefineNgModule<T>(def: {
*/
export function ɵɵsetNgModuleScope(type: any, scope: {
/** List of components, directives, and pipes declared by this module. */
declarations?: Type<any>[] | (() => Type<any>[]);
declarations?: Type<any>[]|(() => Type<any>[]);
/** List of modules or `ModuleWithProviders` imported by this module. */
imports?: Type<any>[] | (() => Type<any>[]);
@ -455,11 +456,11 @@ export function ɵɵsetNgModuleScope(type: any, scope: {
exports?: Type<any>[] | (() => Type<any>[]);
}): void {
return noSideEffects(() => {
const ngModuleDef = getNgModuleDef(type, true);
ngModuleDef.declarations = scope.declarations || EMPTY_ARRAY;
ngModuleDef.imports = scope.imports || EMPTY_ARRAY;
ngModuleDef.exports = scope.exports || EMPTY_ARRAY;
}) as never;
const ngModuleDef = getNgModuleDef(type, true);
ngModuleDef.declarations = scope.declarations || EMPTY_ARRAY;
ngModuleDef.imports = scope.imports || EMPTY_ARRAY;
ngModuleDef.exports = scope.exports || EMPTY_ARRAY;
}) as never;
}
/**
@ -518,13 +519,13 @@ export function ɵɵsetNgModuleScope(type: any, scope: {
*/
function invertObject<T>(
obj?: {[P in keyof T]?: string | [string, string]},
obj?: {[P in keyof T]?: string|[string, string]},
secondary?: {[key: string]: string}): {[P in keyof T]: string} {
if (obj == null) return EMPTY_OBJ as any;
const newLookup: any = {};
for (const minifiedKey in obj) {
if (obj.hasOwnProperty(minifiedKey)) {
let publicName: string|[string, string] = obj[minifiedKey] !;
let publicName: string|[string, string] = obj[minifiedKey]!;
let declaredName = publicName;
if (Array.isArray(publicName)) {
declaredName = publicName[1];
@ -555,142 +556,143 @@ function invertObject<T>(
*
* @codeGenApi
*/
export const ɵɵdefineDirective = ɵɵdefineComponent as any as<T>(directiveDefinition: {
/**
* Directive type, needed to configure the injector.
*/
type: Type<T>;
export const ɵɵdefineDirective =
ɵɵdefineComponent as any as<T>(directiveDefinition: {
/**
* Directive type, needed to configure the injector.
*/
type: Type<T>;
/** The selectors that will be used to match nodes to this directive. */
selectors?: CssSelectorList;
/** The selectors that will be used to match nodes to this directive. */
selectors?: CssSelectorList;
/**
* A map of input names.
*
* The format is in: `{[actualPropertyName: string]:(string|[string, string])}`.
*
* Given:
* ```
* class MyComponent {
* @Input()
* publicInput1: string;
*
* @Input('publicInput2')
* declaredInput2: string;
* }
* ```
*
* is described as:
* ```
* {
* publicInput1: 'publicInput1',
* declaredInput2: ['declaredInput2', 'publicInput2'],
* }
* ```
*
* Which the minifier may translate to:
* ```
* {
* minifiedPublicInput1: 'publicInput1',
* minifiedDeclaredInput2: [ 'publicInput2', 'declaredInput2'],
* }
* ```
*
* This allows the render to re-construct the minified, public, and declared names
* of properties.
*
* NOTE:
* - Because declared and public name are usually same we only generate the array
* `['declared', 'public']` format when they differ.
* - The reason why this API and `outputs` API is not the same is that `NgOnChanges` has
* inconsistent behavior in that it uses declared names rather than minified or public. For
* this reason `NgOnChanges` will be deprecated and removed in future version and this
* API will be simplified to be consistent with `output`.
*/
inputs?: {[P in keyof T]?: string | [string, string]};
/**
* A map of input names.
*
* The format is in: `{[actualPropertyName: string]:(string|[string, string])}`.
*
* Given:
* ```
* class MyComponent {
* @Input()
* publicInput1: string;
*
* @Input('publicInput2')
* declaredInput2: string;
* }
* ```
*
* is described as:
* ```
* {
* publicInput1: 'publicInput1',
* declaredInput2: ['declaredInput2', 'publicInput2'],
* }
* ```
*
* Which the minifier may translate to:
* ```
* {
* minifiedPublicInput1: 'publicInput1',
* minifiedDeclaredInput2: [ 'publicInput2', 'declaredInput2'],
* }
* ```
*
* This allows the render to re-construct the minified, public, and declared names
* of properties.
*
* NOTE:
* - Because declared and public name are usually same we only generate the array
* `['declared', 'public']` format when they differ.
* - The reason why this API and `outputs` API is not the same is that `NgOnChanges` has
* inconsistent behavior in that it uses declared names rather than minified or public. For
* this reason `NgOnChanges` will be deprecated and removed in future version and this
* API will be simplified to be consistent with `output`.
*/
inputs?: {[P in keyof T]?: string | [string, string]};
/**
* A map of output names.
*
* The format is in: `{[actualPropertyName: string]:string}`.
*
* Which the minifier may translate to: `{[minifiedPropertyName: string]:string}`.
*
* This allows the render to re-construct the minified and non-minified names
* of properties.
*/
outputs?: {[P in keyof T]?: string};
/**
* A map of output names.
*
* The format is in: `{[actualPropertyName: string]:string}`.
*
* Which the minifier may translate to: `{[minifiedPropertyName: string]:string}`.
*
* This allows the render to re-construct the minified and non-minified names
* of properties.
*/
outputs?: {[P in keyof T]?: string};
/**
* A list of optional features to apply.
*
* See: {@link NgOnChangesFeature}, {@link ProvidersFeature}, {@link InheritDefinitionFeature}
*/
features?: DirectiveDefFeature[];
/**
* A list of optional features to apply.
*
* See: {@link NgOnChangesFeature}, {@link ProvidersFeature}, {@link InheritDefinitionFeature}
*/
features?: DirectiveDefFeature[];
/**
* Function executed by the parent template to allow child directive to apply host bindings.
*/
hostBindings?: HostBindingsFunction<T>;
/**
* Function executed by the parent template to allow child directive to apply host bindings.
*/
hostBindings?: HostBindingsFunction<T>;
/**
* The number of bindings in this directive `hostBindings` (including pure fn bindings).
*
* Used to calculate the length of the component's LView array, so we
* can pre-fill the array and set the host binding start index.
*/
hostVars?: number;
/**
* The number of bindings in this directive `hostBindings` (including pure fn bindings).
*
* Used to calculate the length of the component's LView array, so we
* can pre-fill the array and set the host binding start index.
*/
hostVars?: number;
/**
* Assign static attribute values to a host element.
*
* This property will assign static attribute values as well as class and style
* values to a host element. Since attribute values can consist of different types of values, the
* `hostAttrs` array must include the values in the following format:
*
* attrs = [
* // static attributes (like `title`, `name`, `id`...)
* attr1, value1, attr2, value,
*
* // a single namespace value (like `x:id`)
* NAMESPACE_MARKER, namespaceUri1, name1, value1,
*
* // another single namespace value (like `x:name`)
* NAMESPACE_MARKER, namespaceUri2, name2, value2,
*
* // a series of CSS classes that will be applied to the element (no spaces)
* CLASSES_MARKER, class1, class2, class3,
*
* // a series of CSS styles (property + value) that will be applied to the element
* STYLES_MARKER, prop1, value1, prop2, value2
* ]
*
* All non-class and non-style attributes must be defined at the start of the list
* first before all class and style values are set. When there is a change in value
* type (like when classes and styles are introduced) a marker must be used to separate
* the entries. The marker values themselves are set via entries found in the
* [AttributeMarker] enum.
*/
hostAttrs?: TAttributes;
/**
* Assign static attribute values to a host element.
*
* This property will assign static attribute values as well as class and style
* values to a host element. Since attribute values can consist of different types of values,
* the `hostAttrs` array must include the values in the following format:
*
* attrs = [
* // static attributes (like `title`, `name`, `id`...)
* attr1, value1, attr2, value,
*
* // a single namespace value (like `x:id`)
* NAMESPACE_MARKER, namespaceUri1, name1, value1,
*
* // another single namespace value (like `x:name`)
* NAMESPACE_MARKER, namespaceUri2, name2, value2,
*
* // a series of CSS classes that will be applied to the element (no spaces)
* CLASSES_MARKER, class1, class2, class3,
*
* // a series of CSS styles (property + value) that will be applied to the element
* STYLES_MARKER, prop1, value1, prop2, value2
* ]
*
* All non-class and non-style attributes must be defined at the start of the list
* first before all class and style values are set. When there is a change in value
* type (like when classes and styles are introduced) a marker must be used to separate
* the entries. The marker values themselves are set via entries found in the
* [AttributeMarker] enum.
*/
hostAttrs?: TAttributes;
/**
* Function to create instances of content queries associated with a given directive.
*/
contentQueries?: ContentQueriesFunction<T>;
/**
* Function to create instances of content queries associated with a given directive.
*/
contentQueries?: ContentQueriesFunction<T>;
/**
* Additional set of instructions specific to view query processing. This could be seen as a
* set of instructions to be inserted into the template function.
*/
viewQuery?: ViewQueriesFunction<T>| null;
/**
* Additional set of instructions specific to view query processing. This could be seen as a
* set of instructions to be inserted into the template function.
*/
viewQuery?: ViewQueriesFunction<T>| null;
/**
* Defines the name that can be used in the template to assign this directive to a variable.
*
* See: {@link Directive.exportAs}
*/
exportAs?: string[];
}) => never;
/**
* Defines the name that can be used in the template to assign this directive to a variable.
*
* See: {@link Directive.exportAs}
*/
exportAs?: string[];
}) => never;
/**
* Create a pipe definition object.
@ -719,12 +721,12 @@ export function ɵɵdefinePipe<T>(pipeDef: {
pure?: boolean
}): never {
return (<PipeDef<T>>{
type: pipeDef.type,
name: pipeDef.name,
factory: null,
pure: pipeDef.pure !== false,
onDestroy: pipeDef.type.prototype.ngOnDestroy || null
}) as never;
type: pipeDef.type,
name: pipeDef.name,
factory: null,
pure: pipeDef.pure !== false,
onDestroy: pipeDef.type.prototype.ngOnDestroy || null
}) as never;
}
/**

View File

@ -21,10 +21,10 @@ import {getFactoryDef} from './definition';
import {NG_ELEMENT_ID, NG_FACTORY_DEF} from './fields';
import {registerPreOrderHooks} from './hooks';
import {DirectiveDef, FactoryFn} from './interfaces/definition';
import {NO_PARENT_INJECTOR, NodeInjectorFactory, PARENT_INJECTOR, RelativeInjectorLocation, RelativeInjectorLocationFlags, TNODE, isFactory} from './interfaces/injector';
import {isFactory, NO_PARENT_INJECTOR, NodeInjectorFactory, PARENT_INJECTOR, RelativeInjectorLocation, RelativeInjectorLocationFlags, TNODE} from './interfaces/injector';
import {AttributeMarker, TContainerNode, TDirectiveHostNode, TElementContainerNode, TElementNode, TNode, TNodeProviderIndexes, TNodeType} from './interfaces/node';
import {isComponentDef, isComponentHost} from './interfaces/type_checks';
import {DECLARATION_COMPONENT_VIEW, DECLARATION_VIEW, INJECTOR, LView, TData, TVIEW, TView, T_HOST} from './interfaces/view';
import {DECLARATION_COMPONENT_VIEW, DECLARATION_VIEW, INJECTOR, LView, T_HOST, TData, TVIEW, TView} from './interfaces/view';
import {assertNodeOfPossibleTypes} from './node_assert';
import {enterDI, leaveDI} from './state';
import {isNameOnlyAttributeMarker} from './util/attrs_utils';
@ -97,7 +97,7 @@ let nextNgElementId = 0;
* @param type The directive token to register
*/
export function bloomAdd(
injectorIndex: number, tView: TView, type: Type<any>| InjectionToken<any>| string): void {
injectorIndex: number, tView: TView, type: Type<any>|InjectionToken<any>|string): void {
ngDevMode && assertEqual(tView.firstCreatePass, true, 'expected firstCreatePass to be true');
let id: number|undefined =
typeof type !== 'string' ? (type as any)[NG_ELEMENT_ID] : type.charCodeAt(0) || 0;
@ -141,7 +141,7 @@ export function bloomAdd(
* @returns Node injector
*/
export function getOrCreateNodeInjectorForNode(
tNode: TElementNode | TContainerNode | TElementContainerNode, hostView: LView): number {
tNode: TElementNode|TContainerNode|TElementContainerNode, hostView: LView): number {
const existingInjectorIndex = getInjectorIndex(tNode, hostView);
if (existingInjectorIndex !== -1) {
return existingInjectorIndex;
@ -175,7 +175,7 @@ export function getOrCreateNodeInjectorForNode(
return injectorIndex;
}
function insertBloom(arr: any[], footer: TNode | null): void {
function insertBloom(arr: any[], footer: TNode|null): void {
arr.push(0, 0, 0, 0, 0, 0, 0, 0, footer);
}
@ -211,7 +211,7 @@ export function getParentInjectorLocation(tNode: TNode, view: LView): RelativeIn
let hostTNode = view[T_HOST];
let viewOffset = 1;
while (hostTNode && hostTNode.injectorIndex === -1) {
view = view[DECLARATION_VIEW] !;
view = view[DECLARATION_VIEW]!;
hostTNode = view ? view[T_HOST] : null;
viewOffset++;
}
@ -229,7 +229,7 @@ export function getParentInjectorLocation(tNode: TNode, view: LView): RelativeIn
* @param token The type or the injection token to be made public
*/
export function diPublicInInjector(
injectorIndex: number, tView: TView, token: InjectionToken<any>| Type<any>): void {
injectorIndex: number, tView: TView, token: InjectionToken<any>|Type<any>): void {
bloomAdd(injectorIndex, tView, token);
}
@ -265,8 +265,9 @@ export function diPublicInInjector(
* @publicApi
*/
export function injectAttributeImpl(tNode: TNode, attrNameToInject: string): string|null {
ngDevMode && assertNodeOfPossibleTypes(
tNode, TNodeType.Container, TNodeType.Element, TNodeType.ElementContainer);
ngDevMode &&
assertNodeOfPossibleTypes(
tNode, TNodeType.Container, TNodeType.Element, TNodeType.ElementContainer);
ngDevMode && assertDefined(tNode, 'expecting tNode');
if (attrNameToInject === 'class') {
return tNode.classes;
@ -327,7 +328,7 @@ export function injectAttributeImpl(tNode: TNode, attrNameToInject: string): str
* @returns the value from the injector, `null` when not found, or `notFoundValue` if provided
*/
export function getOrCreateInjectable<T>(
tNode: TDirectiveHostNode | null, lView: LView, token: Type<T>| InjectionToken<T>,
tNode: TDirectiveHostNode|null, lView: LView, token: Type<T>|InjectionToken<T>,
flags: InjectFlags = InjectFlags.Default, notFoundValue?: any): T|null {
if (tNode !== null) {
const bloomHash = bloomHashBitOrFactory(token);
@ -443,8 +444,8 @@ export function getOrCreateInjectable<T>(
const NOT_FOUND = {};
function searchTokensOnInjector<T>(
injectorIndex: number, lView: LView, token: Type<T>| InjectionToken<T>,
previousTView: TView | null, flags: InjectFlags, hostTElementNode: TNode | null) {
injectorIndex: number, lView: LView, token: Type<T>|InjectionToken<T>,
previousTView: TView|null, flags: InjectFlags, hostTElementNode: TNode|null) {
const currentTView = lView[TVIEW];
const tNode = currentTView.data[injectorIndex + TNODE] as TNode;
// First, we need to determine if view providers can be accessed by the starting element.
@ -490,8 +491,8 @@ function searchTokensOnInjector<T>(
* @returns Index of a found directive or provider, or null when none found.
*/
export function locateDirectiveOrProvider<T>(
tNode: TNode, tView: TView, token: Type<T>| InjectionToken<T>, canAccessViewProviders: boolean,
isHostSpecialCase: boolean | number): number|null {
tNode: TNode, tView: TView, token: Type<T>|InjectionToken<T>, canAccessViewProviders: boolean,
isHostSpecialCase: boolean|number): number|null {
const nodeProviderIndexes = tNode.providerIndexes;
const tInjectables = tView.data;
@ -521,12 +522,12 @@ export function locateDirectiveOrProvider<T>(
}
/**
* Retrieve or instantiate the injectable from the `LView` at particular `index`.
*
* This function checks to see if the value has already been instantiated and if so returns the
* cached `injectable`. Otherwise if it detects that the value is still a factory it
* instantiates the `injectable` and caches the value.
*/
* Retrieve or instantiate the injectable from the `LView` at particular `index`.
*
* This function checks to see if the value has already been instantiated and if so returns the
* cached `injectable`. Otherwise if it detects that the value is still a factory it
* instantiates the `injectable` and caches the value.
*/
export function getNodeInjectable(
lView: LView, tView: TView, index: number, tNode: TDirectiveHostNode): any {
let value = lView[index];
@ -577,8 +578,8 @@ export function getNodeInjectable(
* @returns the matching bit to check in the bloom filter or `null` if the token is not known.
* When the returned value is negative then it represents special values such as `Injector`.
*/
export function bloomHashBitOrFactory(token: Type<any>| InjectionToken<any>| string): number|
Function|undefined {
export function bloomHashBitOrFactory(token: Type<any>|InjectionToken<any>|string): number|Function|
undefined {
ngDevMode && assertDefined(token, 'token must be defined');
if (typeof token === 'string') {
return token.charCodeAt(0) || 0;
@ -588,8 +589,7 @@ export function bloomHashBitOrFactory(token: Type<any>| InjectionToken<any>| str
return (typeof tokenId === 'number' && tokenId > 0) ? tokenId & BLOOM_MASK : tokenId;
}
export function bloomHasToken(
bloomHash: number, injectorIndex: number, injectorView: LView | TData) {
export function bloomHasToken(bloomHash: number, injectorIndex: number, injectorView: LView|TData) {
// 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.
@ -639,9 +639,9 @@ export function ɵɵgetFactoryOf<T>(type: Type<any>): FactoryFn<T>|null {
if (isForwardRef(type)) {
return (() => {
const factory = ɵɵgetFactoryOf<T>(resolveForwardRef(typeAny));
return factory ? factory() : null;
}) as any;
const factory = ɵɵgetFactoryOf<T>(resolveForwardRef(typeAny));
return factory ? factory() : null;
}) as any;
}
let factory = getFactoryDef<T>(typeAny);

View File

@ -1,10 +1,10 @@
/**
* @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
*/
* @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 {initNgDevMode} from '../util/ng_dev_mode';
/**

View File

@ -47,7 +47,8 @@ export function throwErrorIfNoChangesMode(
creationMode: boolean, oldValue: any, currValue: any, propName?: string): never|void {
const field = propName ? ` for '${propName}'` : '';
let msg =
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${field}: '${oldValue}'. Current value: '${currValue}'.`;
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${
field}: '${oldValue}'. Current value: '${currValue}'.`;
if (creationMode) {
msg +=
` It seems like the view has been created after its parent and its children have been dirty checked.` +

View File

@ -64,16 +64,16 @@ const COPY_COMPONENT_FIELDS: Exclude<keyof ComponentDef<unknown>, keyof Directiv
*
* @codeGenApi
*/
export function ɵɵCopyDefinitionFeature(definition: DirectiveDef<any>| ComponentDef<any>): void {
let superType = getSuperType(definition.type) !;
export function ɵɵCopyDefinitionFeature(definition: DirectiveDef<any>|ComponentDef<any>): void {
let superType = getSuperType(definition.type)!;
let superDef: DirectiveDef<any>|ComponentDef<any>|undefined = undefined;
if (isComponentDef(definition)) {
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
superDef = superType.ɵcmp !;
superDef = superType.ɵcmp!;
} else {
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
superDef = superType.ɵdir !;
superDef = superType.ɵdir!;
}
// Needed because `definition` fields are readonly.

View File

@ -27,7 +27,7 @@ type WritableDef = Writable<DirectiveDef<any>|ComponentDef<any>>;
*
* @codeGenApi
*/
export function ɵɵInheritDefinitionFeature(definition: DirectiveDef<any>| ComponentDef<any>): void {
export function ɵɵInheritDefinitionFeature(definition: DirectiveDef<any>|ComponentDef<any>): void {
let superType = getSuperType(definition.type);
let shouldInheritFields = true;
const inheritanceChain: WritableDef[] = [definition];

View File

@ -13,7 +13,7 @@ import {DirectiveDef, DirectiveDefFeature} from '../interfaces/definition';
const PRIVATE_PREFIX = '__ngOnChanges_';
type OnChangesExpando = OnChanges & {
type OnChangesExpando = OnChanges&{
__ngOnChanges_: SimpleChanges|null|undefined;
// tslint:disable-next-line:no-any Can hold any value
[key: string]: any;
@ -45,7 +45,7 @@ type OnChangesExpando = OnChanges & {
export function ɵɵNgOnChangesFeature<T>(definition: DirectiveDef<T>): void {
if (definition.type.prototype.ngOnChanges) {
definition.setInput = ngOnChangesSetInput;
(definition as{onChanges: Function}).onChanges = wrapOnChanges();
(definition as {onChanges: Function}).onChanges = wrapOnChanges();
}
}
@ -61,9 +61,9 @@ function wrapOnChanges() {
const current = simpleChangesStore && simpleChangesStore.current;
if (current) {
const previous = simpleChangesStore !.previous;
const previous = simpleChangesStore!.previous;
if (previous === EMPTY_OBJ) {
simpleChangesStore !.previous = current;
simpleChangesStore!.previous = current;
} else {
// New changes are copied to the previous store, so that we don't lose history for inputs
// which were not changed this time
@ -71,7 +71,7 @@ function wrapOnChanges() {
previous[key] = current[key];
}
}
simpleChangesStore !.current = null;
simpleChangesStore!.current = null;
this.ngOnChanges(current);
}
};
@ -84,7 +84,7 @@ function ngOnChangesSetInput<T>(
const current = simpleChangesStore.current || (simpleChangesStore.current = {});
const previous = simpleChangesStore.previous;
const declaredName = (this.declaredInputs as{[key: string]: string})[publicName];
const declaredName = (this.declaredInputs as {[key: string]: string})[publicName];
const previousChange = previous[declaredName];
current[declaredName] = new SimpleChange(
previousChange && previousChange.currentValue, value, previous === EMPTY_OBJ);

View File

@ -16,4 +16,4 @@
*/
export {applyChanges} from './util/change_detection_utils';
export {Listener, getComponent, getContext, getDirectives, getHostElement, getInjector, getListeners, getOwningComponent, getRootComponents} from './util/discovery_utils';
export {getComponent, getContext, getDirectives, getHostElement, getInjector, getListeners, getOwningComponent, getRootComponents, Listener} from './util/discovery_utils';

View File

@ -79,8 +79,8 @@ export function registerPostOrderHooks(tView: TView, tNode: TNode): void {
if (directiveDef.afterContentChecked) {
(tView.contentHooks || (tView.contentHooks = [])).push(i, directiveDef.afterContentChecked);
(tView.contentCheckHooks || (tView.contentCheckHooks = [
])).push(i, directiveDef.afterContentChecked);
(tView.contentCheckHooks || (tView.contentCheckHooks = []))
.push(i, directiveDef.afterContentChecked);
}
if (directiveDef.afterViewInit) {
@ -132,7 +132,7 @@ export function registerPostOrderHooks(tView: TView, tNode: TNode): void {
* - number: execute hooks only from the saved index until that node index exclusive (pre-order
* case, when executing select(number))
*/
export function executeCheckHooks(lView: LView, hooks: HookData, nodeIndex?: number | null) {
export function executeCheckHooks(lView: LView, hooks: HookData, nodeIndex?: number|null) {
callHooks(lView, hooks, InitPhaseState.InitPhaseCompleted, nodeIndex);
}
@ -150,10 +150,11 @@ export function executeCheckHooks(lView: LView, hooks: HookData, nodeIndex?: num
* case, when executing select(number))
*/
export function executeInitAndCheckHooks(
lView: LView, hooks: HookData, initPhase: InitPhaseState, nodeIndex?: number | null) {
ngDevMode && assertNotEqual(
initPhase, InitPhaseState.InitPhaseCompleted,
'Init pre-order hooks should not be called more than once');
lView: LView, hooks: HookData, initPhase: InitPhaseState, nodeIndex?: number|null) {
ngDevMode &&
assertNotEqual(
initPhase, InitPhaseState.InitPhaseCompleted,
'Init pre-order hooks should not be called more than once');
if ((lView[FLAGS] & LViewFlags.InitPhaseStateMask) === initPhase) {
callHooks(lView, hooks, initPhase, nodeIndex);
}
@ -188,17 +189,18 @@ export function incrementInitPhaseFlags(lView: LView, initPhase: InitPhaseState)
*/
function callHooks(
currentView: LView, arr: HookData, initPhase: InitPhaseState,
currentNodeIndex: number | null | undefined): void {
ngDevMode && assertEqual(
getCheckNoChangesMode(), false,
'Hooks should never be run in the check no changes mode.');
currentNodeIndex: number|null|undefined): void {
ngDevMode &&
assertEqual(
getCheckNoChangesMode(), false,
'Hooks should never be run in the check no changes mode.');
const startIndex = currentNodeIndex !== undefined ?
(currentView[PREORDER_HOOK_FLAGS] & PreOrderHookFlags.IndexOfTheNextPreOrderHookMaskMask) :
0;
const nodeIndexLimit = currentNodeIndex != null ? currentNodeIndex : -1;
let lastNodeIndexFound = 0;
for (let i = startIndex; i < arr.length; i++) {
const hook = arr[i + 1] as() => void;
const hook = arr[i + 1] as () => void;
if (typeof hook === 'number') {
lastNodeIndexFound = arr[i] as number;
if (currentNodeIndex != null && lastNodeIndexFound >= currentNodeIndex) {
@ -229,7 +231,7 @@ function callHooks(
*/
function callHook(currentView: LView, initPhase: InitPhaseState, arr: HookData, i: number) {
const isInitHook = arr[i] < 0;
const hook = arr[i + 1] as() => void;
const hook = arr[i + 1] as () => void;
const directiveIndex = isInitHook ? -arr[i] : arr[i] as number;
const directive = currentView[directiveIndex];
if (isInitHook) {

View File

@ -8,11 +8,12 @@
import '../util/ng_i18n_closure_mode';
import {DEFAULT_LOCALE_ID, getPluralCase} from '../i18n/localization';
import {SRCSET_ATTRS, URI_ATTRS, VALID_ATTRS, VALID_ELEMENTS, getTemplateContent} from '../sanitization/html_sanitizer';
import {getTemplateContent, SRCSET_ATTRS, URI_ATTRS, VALID_ATTRS, VALID_ELEMENTS} from '../sanitization/html_sanitizer';
import {InertBodyHelper} from '../sanitization/inert_body';
import {_sanitizeUrl, sanitizeSrcset} from '../sanitization/url_sanitizer';
import {addAllToArray} from '../util/array_utils';
import {assertDataInRange, assertDefined, assertEqual} from '../util/assert';
import {bindingUpdated} from './bindings';
import {attachPatchData} from './context_discovery';
import {setDelayProjection} from './instructions/all';
@ -25,7 +26,7 @@ import {TElementNode, TIcuContainerNode, TNode, TNodeFlags, TNodeType, TProjecti
import {RComment, RElement, RText} from './interfaces/renderer';
import {SanitizerFn} from './interfaces/sanitization';
import {isLContainer} from './interfaces/type_checks';
import {HEADER_OFFSET, LView, RENDERER, TVIEW, TView, T_HOST} from './interfaces/view';
import {HEADER_OFFSET, LView, RENDERER, T_HOST, TVIEW, TView} from './interfaces/view';
import {appendChild, applyProjection, createTextNode, nativeRemoveNode} from './node_manipulation';
import {getBindingIndex, getIsParent, getLView, getPreviousOrParentTNode, getTView, nextBindingIndex, setIsNotParent, setPreviousOrParentTNode} from './state';
import {renderStringify} from './util/misc_utils';
@ -105,14 +106,14 @@ interface IcuCase {
* @param pattern (sub)Pattern to be broken.
*
*/
function extractParts(pattern: string): (string | IcuExpression)[] {
function extractParts(pattern: string): (string|IcuExpression)[] {
if (!pattern) {
return [];
}
let prevPos = 0;
const braceStack = [];
const results: (string | IcuExpression)[] = [];
const results: (string|IcuExpression)[] = [];
const braces = /[{}]/g;
// lastIndex doesn't get set to 0 so we have to.
braces.lastIndex = 0;
@ -158,7 +159,7 @@ function extractParts(pattern: string): (string | IcuExpression)[] {
*/
function parseICUBlock(pattern: string): IcuExpression {
const cases = [];
const values: (string | IcuExpression)[][] = [];
const values: (string|IcuExpression)[][] = [];
let icuType = IcuType.plural;
let mainBinding = 0;
pattern = pattern.replace(ICU_BLOCK_REGEXP, function(str: string, binding: string, type: string) {
@ -219,7 +220,8 @@ function removeInnerTemplateTranslation(message: string): string {
ngDevMode &&
assertEqual(
inTemplate, false,
`Tag mismatch: unable to find the end of the sub-template in the translation "${message}"`);
`Tag mismatch: unable to find the end of the sub-template in the translation "${
message}"`);
res += message.substr(index);
return res;
@ -263,7 +265,7 @@ export function getTranslationForTemplate(message: string, subTemplateIndex?: nu
*/
function generateBindingUpdateOpCodes(
str: string, destinationNode: number, attrName?: string,
sanitizeFn: SanitizerFn | null = null): I18nUpdateOpCodes {
sanitizeFn: SanitizerFn|null = null): I18nUpdateOpCodes {
const updateOpCodes: I18nUpdateOpCodes = [null, null]; // Alloc space for mask and size
const textParts = str.split(BINDING_REGEXP);
let mask = 0;
@ -508,7 +510,7 @@ function i18nStartFirstPass(
}
function appendI18nNode(
tView: TView, tNode: TNode, parentTNode: TNode, previousTNode: TNode | null,
tView: TView, tNode: TNode, parentTNode: TNode, previousTNode: TNode|null,
lView: LView): TNode {
ngDevMode && ngDevMode.rendererMoveNode++;
const nextNode = tNode.next;
@ -577,7 +579,7 @@ function appendI18nNode(
* @codeGenApi
*/
export function ɵɵi18nPostprocess(
message: string, replacements: {[key: string]: (string | string[])} = {}): string {
message: string, replacements: {[key: string]: (string|string[])} = {}): string {
/**
* Step 1: resolve all multi-value placeholders like [<5B>#5<>|<7C>*1:1<><31>#2:1<>|<7C>#4:1<>]
*
@ -660,7 +662,7 @@ export function ɵɵi18nPostprocess(
if (!list.length) {
throw new Error(`i18n postprocess: unmatched ICU - ${match} with key: ${key}`);
}
return list.shift() !;
return list.shift()!;
}
return match;
});
@ -687,9 +689,10 @@ export function ɵɵi18nEnd(): void {
* See `i18nEnd` above.
*/
function i18nEndFirstPass(tView: TView, lView: LView) {
ngDevMode && assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'i18nEnd should be called before any binding');
ngDevMode &&
assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'i18nEnd should be called before any binding');
const rootIndex = i18nIndexStack[i18nIndexStackPointer--];
const tI18n = tView.data[rootIndex + HEADER_OFFSET] as TI18n;
@ -709,8 +712,9 @@ function i18nEndFirstPass(tView: TView, lView: LView) {
}
// Check if an element has any local refs and skip them
const tNode = getTNode(tView, index);
if (tNode && (tNode.type === TNodeType.Container || tNode.type === TNodeType.Element ||
tNode.type === TNodeType.ElementContainer) &&
if (tNode &&
(tNode.type === TNodeType.Container || tNode.type === TNodeType.Element ||
tNode.type === TNodeType.ElementContainer) &&
tNode.localNames !== null) {
// Divide by 2 to get the number of local refs,
// since they are stored as an array that also includes directive indexes,
@ -725,8 +729,8 @@ function i18nEndFirstPass(tView: TView, lView: LView) {
* Creates and stores the dynamic TNode, and unhooks it from the tree for now.
*/
function createDynamicNodeAtIndex(
tView: TView, lView: LView, index: number, type: TNodeType, native: RElement | RText | null,
name: string | null): TElementNode|TIcuContainerNode {
tView: TView, lView: LView, index: number, type: TNodeType, native: RElement|RText|null,
name: string|null): TElementNode|TIcuContainerNode {
const previousOrParentTNode = getPreviousOrParentTNode();
ngDevMode && assertDataInRange(lView, index + HEADER_OFFSET);
lView[index + HEADER_OFFSET] = native;
@ -766,16 +770,16 @@ function readCreateOpCodes(
if (destinationNodeIndex === index) {
// If the destination node is `i18nStart`, we don't have a
// top-level node and we should use the host node instead
destinationTNode = lView[T_HOST] !;
destinationTNode = lView[T_HOST]!;
} else {
destinationTNode = getTNode(tView, destinationNodeIndex);
}
ngDevMode &&
assertDefined(
currentTNode !,
currentTNode!,
`You need to create or select a node before you can insert it into the DOM`);
previousTNode =
appendI18nNode(tView, currentTNode !, destinationTNode, previousTNode, lView);
appendI18nNode(tView, currentTNode!, destinationTNode, previousTNode, lView);
break;
case I18nMutateOpCode.Select:
// Negative indicies indicate that a given TNode is a sibling node, not a parent node
@ -811,9 +815,10 @@ function readCreateOpCodes(
case COMMENT_MARKER:
const commentValue = createOpCodes[++i] as string;
const commentNodeIndex = createOpCodes[++i] as number;
ngDevMode && assertEqual(
typeof commentValue, 'string',
`Expected "${commentValue}" to be a comment node value`);
ngDevMode &&
assertEqual(
typeof commentValue, 'string',
`Expected "${commentValue}" to be a comment node value`);
const commentRNode = renderer.createComment(commentValue);
ngDevMode && ngDevMode.rendererCreateComment++;
previousTNode = currentTNode;
@ -828,9 +833,10 @@ function readCreateOpCodes(
case ELEMENT_MARKER:
const tagNameValue = createOpCodes[++i] as string;
const elementNodeIndex = createOpCodes[++i] as number;
ngDevMode && assertEqual(
typeof tagNameValue, 'string',
`Expected "${tagNameValue}" to be an element node tag name`);
ngDevMode &&
assertEqual(
typeof tagNameValue, 'string',
`Expected "${tagNameValue}" to be an element node tag name`);
const elementRNode = renderer.createElement(tagNameValue);
ngDevMode && ngDevMode.rendererCreateElement++;
previousTNode = currentTNode;
@ -850,7 +856,7 @@ function readCreateOpCodes(
}
function readUpdateOpCodes(
updateOpCodes: I18nUpdateOpCodes, icus: TIcu[] | null, bindingsStartIndex: number,
updateOpCodes: I18nUpdateOpCodes, icus: TIcu[]|null, bindingsStartIndex: number,
changeMask: number, tView: TView, lView: LView, bypassCheckBit = false) {
let caseCreated = false;
for (let i = 0; i < updateOpCodes.length; i++) {
@ -887,7 +893,7 @@ function readUpdateOpCodes(
break;
case I18nUpdateOpCode.IcuSwitch:
tIcuIndex = updateOpCodes[++j] as number;
tIcu = icus ![tIcuIndex];
tIcu = icus![tIcuIndex];
icuTNode = getTNode(tView, nodeIndex) as TIcuContainerNode;
// If there is an active case, delete the old nodes
if (icuTNode.activeCaseIndex !== null) {
@ -910,7 +916,7 @@ function readUpdateOpCodes(
const activeIndex = nestedIcuTNode.activeCaseIndex;
if (activeIndex !== null) {
const nestedIcuTIndex = removeOpCode >>> I18nMutateOpCode.SHIFT_REF;
const nestedTIcu = icus ![nestedIcuTIndex];
const nestedTIcu = icus![nestedIcuTIndex];
addAllToArray(nestedTIcu.remove[activeIndex], removeCodes);
}
break;
@ -929,7 +935,7 @@ function readUpdateOpCodes(
break;
case I18nUpdateOpCode.IcuUpdate:
tIcuIndex = updateOpCodes[++j] as number;
tIcu = icus ![tIcuIndex];
tIcu = icus![tIcuIndex];
icuTNode = getTNode(tView, nodeIndex) as TIcuContainerNode;
if (icuTNode.activeCaseIndex !== null) {
readUpdateOpCodes(
@ -1215,7 +1221,7 @@ function parseIcuCase(
if (!inertBodyElement) {
throw new Error('Unable to generate inert body element');
}
const wrapper = getTemplateContent(inertBodyElement !) as Element || inertBodyElement;
const wrapper = getTemplateContent(inertBodyElement!) as Element || inertBodyElement;
const opCodes: IcuCase = {vars: 0, childIcus: [], create: [], remove: [], update: []};
parseNodes(wrapper.firstChild, opCodes, parentIndex, nestedIcus, tIcus, expandoStartIndex);
return opCodes;
@ -1234,7 +1240,7 @@ const NESTED_ICU = /<2F>(\d+)<29>/;
* @param expandoStartIndex Expando start index for the current ICU expression
*/
function parseNodes(
currentNode: Node | null, icuCase: IcuCase, parentIndex: number, nestedIcus: IcuExpression[],
currentNode: Node|null, icuCase: IcuCase, parentIndex: number, nestedIcus: IcuExpression[],
tIcus: TIcu[], expandoStartIndex: number) {
if (currentNode) {
const nestedIcusToCreate: [IcuExpression, number][] = [];
@ -1254,7 +1260,7 @@ function parseNodes(
parentIndex << I18nMutateOpCode.SHIFT_PARENT | I18nMutateOpCode.AppendChild);
const elAttrs = element.attributes;
for (let i = 0; i < elAttrs.length; i++) {
const attr = elAttrs.item(i) !;
const attr = elAttrs.item(i)!;
const lowerAttrName = attr.name.toLowerCase();
const hasBinding = !!attr.value.match(BINDING_REGEXP);
// we assume the input string is safe, unless it's using a binding
@ -1276,8 +1282,8 @@ function parseNodes(
}
} else {
ngDevMode &&
console.warn(
`WARNING: ignoring unsafe attribute value ${lowerAttrName} on element ${tagName} (see http://g.co/ng/security#xss)`);
console.warn(`WARNING: ignoring unsafe attribute value ${
lowerAttrName} on element ${tagName} (see http://g.co/ng/security#xss)`);
}
} else {
icuCase.create.push(
@ -1324,7 +1330,7 @@ function parseNodes(
// We do not handle any other type of element
icuCase.vars--;
}
currentNode = nextNode !;
currentNode = nextNode!;
}
for (let i = 0; i < nestedIcusToCreate.length; i++) {

View File

@ -16,13 +16,14 @@ import {getComponent, getDirectives, getHostElement, getRenderedText} from './ut
export {ComponentFactory, ComponentFactoryResolver, ComponentRef, injectComponentFactoryResolver} from './component_ref';
export {ɵɵgetFactoryOf, ɵɵgetInheritedFactory} from './di';
export {getLocaleId, setLocaleId, ɵɵi18n, ɵɵi18nApply, ɵɵi18nAttributes, ɵɵi18nEnd, ɵɵi18nExp, ɵɵi18nPostprocess, ɵɵi18nStart,} from './i18n';
// clang-format off
export {
detectChanges,
markDirty,
store,
tick,
ɵɵadvance,
ɵɵattribute,
ɵɵattributeInterpolate1,
@ -54,7 +55,6 @@ export {
ɵɵcontainerRefreshStart,
ɵɵdirectiveInject,
ɵɵinvalidFactory,
ɵɵelement,
ɵɵelementContainer,
@ -69,7 +69,9 @@ export {
ɵɵembeddedViewStart,
ɵɵgetCurrentView,
ɵɵhostProperty,
ɵɵinjectAttribute,
ɵɵinvalidFactory,
ɵɵlistener,
@ -81,7 +83,6 @@ export {
ɵɵprojection,
ɵɵprojectionDef,
ɵɵhostProperty,
ɵɵproperty,
ɵɵpropertyInterpolate,
ɵɵpropertyInterpolate1,
@ -98,7 +99,6 @@ export {
// TODO: remove `select` once we've refactored all of the tests not to use it.
ɵɵselect,
ɵɵadvance,
ɵɵstyleMap,
ɵɵstyleMapInterpolate1,
ɵɵstyleMapInterpolate2,
@ -139,37 +139,14 @@ export {
ɵɵupdateSyntheticHostBinding,
} from './instructions/all';
export {RenderFlags} from './interfaces/definition';
export {CssSelectorList, ProjectionSlots} from './interfaces/projection';
export {
ɵɵrestoreView,
ɵɵenableBindings,
ɵɵdisableBindings,
} from './state';
export {
ɵɵi18n,
ɵɵi18nAttributes,
ɵɵi18nExp,
ɵɵi18nStart,
ɵɵi18nEnd,
ɵɵi18nApply,
ɵɵi18nPostprocess,
getLocaleId,
setLocaleId,
} from './i18n';
export {NgModuleFactory, NgModuleRef, NgModuleType} from './ng_module_ref';
export {
AttributeMarker
} from './interfaces/node';
export {CssSelectorList, ProjectionSlots} from './interfaces/projection';
export {
setClassMetadata,
} from './metadata';
export {NgModuleFactory, NgModuleRef, NgModuleType} from './ng_module_ref';
export {
ɵɵpipe,
ɵɵpipeBind1,
@ -178,16 +155,6 @@ export {
ɵɵpipeBind4,
ɵɵpipeBindV,
} from './pipe';
export {
ɵɵqueryRefresh,
ɵɵviewQuery,
ɵɵstaticViewQuery,
ɵɵloadQuery,
ɵɵcontentQuery,
ɵɵstaticContentQuery
} from './query';
export {
ɵɵpureFunction0,
ɵɵpureFunction1,
@ -200,41 +167,51 @@ export {
ɵɵpureFunction8,
ɵɵpureFunctionV,
} from './pure_function';
export {
ɵɵcontentQuery,
ɵɵloadQuery,
ɵɵqueryRefresh,
ɵɵstaticContentQuery
,
ɵɵstaticViewQuery,
ɵɵviewQuery} from './query';
export {
ɵɵdisableBindings,
export {ɵɵtemplateRefExtractor, ɵɵinjectPipeChangeDetectorRef} from './view_engine_compatibility_prebound';
export {ɵɵresolveWindow, ɵɵresolveDocument, ɵɵresolveBody} from './util/misc_utils';
ɵɵenableBindings,
ɵɵrestoreView,
} from './state';
export {NO_CHANGE} from './tokens';
export { ɵɵresolveBody, ɵɵresolveDocument,ɵɵresolveWindow} from './util/misc_utils';
export { ɵɵinjectPipeChangeDetectorRef,ɵɵtemplateRefExtractor} from './view_engine_compatibility_prebound';
// clang-format on
export {
ComponentDef,
ɵɵComponentDefWithMeta,
ɵɵFactoryDef,
ComponentTemplate,
ComponentType,
DirectiveDef,
ɵɵDirectiveDefWithMeta,
DirectiveType,
ɵɵNgOnChangesFeature,
ɵɵCopyDefinitionFeature,
ɵɵInheritDefinitionFeature,
ɵɵProvidersFeature,
PipeDef,
ɵɵPipeDefWithMeta,
getComponent,
getDirectives,
getHostElement,
getRenderedText,
LifecycleHooksFeature,
PipeDef,
renderComponent,
whenRendered,
ɵɵComponentDefWithMeta,
ɵɵCopyDefinitionFeature,
ɵɵdefineComponent,
ɵɵdefineDirective,
ɵɵdefineNgModule,
ɵɵdefinePipe,
getHostElement,
getComponent,
getDirectives,
getRenderedText,
renderComponent,
ɵɵDirectiveDefWithMeta,
ɵɵFactoryDef,
ɵɵInheritDefinitionFeature,
ɵɵNgOnChangesFeature,
ɵɵPipeDefWithMeta,
ɵɵProvidersFeature,
ɵɵsetComponentScope,
ɵɵsetNgModuleScope,
whenRendered,
};
export {NO_CHANGE} from './tokens';

View File

@ -19,21 +19,21 @@ import {getCheckNoChangesMode, getLView, getSelectedIndex, getTView, setSelected
*
* ```ts
* (rf: RenderFlags, ctx: any) => {
* if (rf & 1) {
* text(0, 'Hello');
* text(1, 'Goodbye')
* element(2, 'div');
* }
* if (rf & 2) {
* advance(2); // Advance twice to the <div>.
* property('title', 'test');
* }
* }
* ```
* @param delta Number of elements to advance forwards by.
*
* @codeGenApi
*/
* if (rf & 1) {
* text(0, 'Hello');
* text(1, 'Goodbye')
* element(2, 'div');
* }
* if (rf & 2) {
* advance(2); // Advance twice to the <div>.
* property('title', 'test');
* }
* }
* ```
* @param delta Number of elements to advance forwards by.
*
* @codeGenApi
*/
export function ɵɵadvance(delta: number): void {
ngDevMode && assertGreaterThan(delta, 0, 'Can only advance forward');
selectIndexInternal(getTView(), getLView(), getSelectedIndex() + delta, getCheckNoChangesMode());

View File

@ -26,7 +26,7 @@ import {elementAttributeInternal, storePropertyBindingMetadata} from './shared';
* @codeGenApi
*/
export function ɵɵattribute(
name: string, value: any, sanitizer?: SanitizerFn | null,
name: string, value: any, sanitizer?: SanitizerFn|null,
namespace?: string): typeof ɵɵattribute {
const lView = getLView();
const bindingIndex = nextBindingIndex();

View File

@ -130,9 +130,10 @@ export function ɵɵattributeInterpolate3(
if (interpolatedValue !== NO_CHANGE) {
const tNode = getSelectedTNode();
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
ngDevMode && storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0,
i1, suffix);
ngDevMode &&
storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0, i1,
suffix);
}
return ɵɵattributeInterpolate3;
}
@ -177,9 +178,10 @@ export function ɵɵattributeInterpolate4(
if (interpolatedValue !== NO_CHANGE) {
const tNode = getSelectedTNode();
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
ngDevMode && storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 4, prefix, i0,
i1, i2, suffix);
ngDevMode &&
storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 4, prefix, i0, i1, i2,
suffix);
}
return ɵɵattributeInterpolate4;
}
@ -227,9 +229,10 @@ export function ɵɵattributeInterpolate5(
if (interpolatedValue !== NO_CHANGE) {
const tNode = getSelectedTNode();
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
ngDevMode && storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 5, prefix, i0,
i1, i2, i3, suffix);
ngDevMode &&
storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 5, prefix, i0, i1, i2,
i3, suffix);
}
return ɵɵattributeInterpolate5;
}
@ -279,9 +282,10 @@ export function ɵɵattributeInterpolate6(
if (interpolatedValue !== NO_CHANGE) {
const tNode = getSelectedTNode();
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
ngDevMode && storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 6, prefix, i0,
i1, i2, i3, i4, suffix);
ngDevMode &&
storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 6, prefix, i0, i1, i2,
i3, i4, suffix);
}
return ɵɵattributeInterpolate6;
}
@ -333,9 +337,10 @@ export function ɵɵattributeInterpolate7(
if (interpolatedValue !== NO_CHANGE) {
const tNode = getSelectedTNode();
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
ngDevMode && storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 7, prefix, i0,
i1, i2, i3, i4, i5, suffix);
ngDevMode &&
storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 7, prefix, i0, i1, i2,
i3, i4, i5, suffix);
}
return ɵɵattributeInterpolate7;
}
@ -389,9 +394,10 @@ export function ɵɵattributeInterpolate8(
if (interpolatedValue !== NO_CHANGE) {
const tNode = getSelectedTNode();
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
ngDevMode && storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 8, prefix, i0,
i1, i2, i3, i4, i5, i6, suffix);
ngDevMode &&
storePropertyBindingMetadata(
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 8, prefix, i0, i1, i2,
i3, i4, i5, i6, suffix);
}
return ɵɵattributeInterpolate8;
}

View File

@ -35,7 +35,7 @@ export function detectChanges(component: {}): void {
*/
export function markDirty(component: {}): void {
ngDevMode && assertDefined(component, 'component');
const rootView = markViewDirty(getComponentViewByInstance(component)) !;
const rootView = markViewDirty(getComponentViewByInstance(component))!;
ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
scheduleTick(rootView[CONTEXT] as RootContext, RootContextFlags.DetectChanges);

View File

@ -13,11 +13,12 @@ import {ACTIVE_INDEX, CONTAINER_HEADER_OFFSET, LContainer} from '../interfaces/c
import {ComponentTemplate} from '../interfaces/definition';
import {LocalRefExtractor, TAttributes, TContainerNode, TNode, TNodeType, TViewNode} from '../interfaces/node';
import {isDirectiveHost} from '../interfaces/type_checks';
import {FLAGS, HEADER_OFFSET, InitPhaseState, LView, LViewFlags, RENDERER, TView, TViewType, T_HOST} from '../interfaces/view';
import {FLAGS, HEADER_OFFSET, InitPhaseState, LView, LViewFlags, RENDERER, T_HOST, TView, TViewType} from '../interfaces/view';
import {assertNodeType} from '../node_assert';
import {appendChild, removeView} from '../node_manipulation';
import {getBindingIndex, getCheckNoChangesMode, getIsParent, getLView, getPreviousOrParentTNode, getTView, setIsNotParent, setPreviousOrParentTNode} from '../state';
import {getConstant, getLContainerActiveIndex, load} from '../util/view_utils';
import {addToViewTree, createDirectivesInstances, createLContainer, createTNode, createTView, getOrCreateTNode, resolveDirectives, saveResolvedLocalsInData} from './shared';
@ -45,9 +46,9 @@ export function ɵɵcontainer(index: number): void {
}
function templateFirstCreatePass(
index: number, tView: TView, lView: LView, templateFn: ComponentTemplate<any>| null,
decls: number, vars: number, tagName?: string | null, attrsIndex?: number | null,
localRefsIndex?: number | null): TContainerNode {
index: number, tView: TView, lView: LView, templateFn: ComponentTemplate<any>|null,
decls: number, vars: number, tagName?: string|null, attrsIndex?: number|null,
localRefsIndex?: number|null): TContainerNode {
ngDevMode && assertFirstCreatePass(tView);
ngDevMode && ngDevMode.firstCreatePass++;
const tViewConsts = tView.consts;
@ -94,8 +95,8 @@ function templateFirstCreatePass(
* @codeGenApi
*/
export function ɵɵtemplate(
index: number, templateFn: ComponentTemplate<any>| null, decls: number, vars: number,
tagName?: string | null, attrsIndex?: number | null, localRefsIndex?: number | null,
index: number, templateFn: ComponentTemplate<any>|null, decls: number, vars: number,
tagName?: string|null, attrsIndex?: number|null, localRefsIndex?: number|null,
localRefExtractor?: LocalRefExtractor) {
const lView = getLView();
const tView = getTView();
@ -172,7 +173,7 @@ export function ɵɵcontainerRefreshEnd(): void {
} else {
ngDevMode && assertNodeType(previousOrParentTNode, TNodeType.View);
ngDevMode && assertHasParent(previousOrParentTNode);
previousOrParentTNode = previousOrParentTNode.parent !;
previousOrParentTNode = previousOrParentTNode.parent!;
setPreviousOrParentTNode(previousOrParentTNode, false);
}
@ -188,11 +189,12 @@ export function ɵɵcontainerRefreshEnd(): void {
}
function containerInternal(
tView: TView, lView: LView, nodeIndex: number, tagName: string | null,
attrs: TAttributes | null): TContainerNode {
ngDevMode && assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'container nodes should be created before any bindings');
tView: TView, lView: LView, nodeIndex: number, tagName: string|null,
attrs: TAttributes|null): TContainerNode {
ngDevMode &&
assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'container nodes should be created before any bindings');
const adjustedIndex = nodeIndex + HEADER_OFFSET;
ngDevMode && assertDataInRange(lView, nodeIndex + HEADER_OFFSET);

View File

@ -37,10 +37,10 @@ import {getLView, getPreviousOrParentTNode} from '../state';
*
* @codeGenApi
*/
export function ɵɵdirectiveInject<T>(token: Type<T>| InjectionToken<T>): T;
export function ɵɵdirectiveInject<T>(token: Type<T>| InjectionToken<T>, flags: InjectFlags): T;
export function ɵɵdirectiveInject<T>(token: Type<T>|InjectionToken<T>): T;
export function ɵɵdirectiveInject<T>(token: Type<T>|InjectionToken<T>, flags: InjectFlags): T;
export function ɵɵdirectiveInject<T>(
token: Type<T>| InjectionToken<T>, flags = InjectFlags.Default): T|null {
token: Type<T>|InjectionToken<T>, flags = InjectFlags.Default): T|null {
const lView = getLView();
// Fall back to inject() if view hasn't been created. This situation can happen in tests
// if inject utilities are used before bootstrapping.

View File

@ -10,23 +10,24 @@ import {assertDataInRange, assertDefined, assertEqual} from '../../util/assert';
import {assertFirstCreatePass, assertHasParent} from '../assert';
import {attachPatchData} from '../context_discovery';
import {registerPostOrderHooks} from '../hooks';
import {TAttributes, TElementNode, TNode, TNodeType, hasClassInput, hasStyleInput} from '../interfaces/node';
import {hasClassInput, hasStyleInput, TAttributes, TElementNode, TNode, TNodeType} from '../interfaces/node';
import {RElement} from '../interfaces/renderer';
import {isContentQueryHost, isDirectiveHost} from '../interfaces/type_checks';
import {HEADER_OFFSET, LView, RENDERER, TVIEW, TView, T_HOST} from '../interfaces/view';
import {HEADER_OFFSET, LView, RENDERER, T_HOST, TVIEW, TView} from '../interfaces/view';
import {assertNodeType} from '../node_assert';
import {appendChild, writeDirectClass, writeDirectStyle} from '../node_manipulation';
import {decreaseElementDepthCount, getBindingIndex, getElementDepthCount, getIsParent, getLView, getNamespace, getPreviousOrParentTNode, getTView, increaseElementDepthCount, setIsNotParent, setPreviousOrParentTNode} from '../state';
import {computeStaticStyling} from '../styling/static_styling';
import {setUpAttributes} from '../util/attrs_utils';
import {getConstant} from '../util/view_utils';
import {setDirectiveInputsWhichShadowsStyling} from './property';
import {createDirectivesInstances, elementCreate, executeContentQueries, getOrCreateTNode, matchingSchemas, resolveDirectives, saveResolvedLocalsInData} from './shared';
function elementStartFirstCreatePass(
index: number, tView: TView, lView: LView, native: RElement, name: string,
attrsIndex?: number | null, localRefsIndex?: number): TElementNode {
attrsIndex?: number|null, localRefsIndex?: number): TElementNode {
ngDevMode && assertFirstCreatePass(tView);
ngDevMode && ngDevMode.firstCreatePass++;
@ -64,14 +65,15 @@ function elementStartFirstCreatePass(
* @codeGenApi
*/
export function ɵɵelementStart(
index: number, name: string, attrsIndex?: number | null, localRefsIndex?: number): void {
index: number, name: string, attrsIndex?: number|null, localRefsIndex?: number): void {
const lView = getLView();
const tView = getTView();
const adjustedIndex = HEADER_OFFSET + index;
ngDevMode && assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'elements should be created before any bindings');
ngDevMode &&
assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'elements should be created before any bindings');
ngDevMode && ngDevMode.rendererCreateElement++;
ngDevMode && assertDataInRange(lView, adjustedIndex);
@ -128,7 +130,7 @@ export function ɵɵelementEnd(): void {
setIsNotParent();
} else {
ngDevMode && assertHasParent(getPreviousOrParentTNode());
previousOrParentTNode = previousOrParentTNode.parent !;
previousOrParentTNode = previousOrParentTNode.parent!;
setPreviousOrParentTNode(previousOrParentTNode, false);
}
@ -142,7 +144,7 @@ export function ɵɵelementEnd(): void {
if (tView.firstCreatePass) {
registerPostOrderHooks(tView, previousOrParentTNode);
if (isContentQueryHost(previousOrParentTNode)) {
tView.queries !.elementEnd(previousOrParentTNode);
tView.queries!.elementEnd(previousOrParentTNode);
}
}
@ -166,7 +168,7 @@ export function ɵɵelementEnd(): void {
* @codeGenApi
*/
export function ɵɵelement(
index: number, name: string, attrsIndex?: number | null, localRefsIndex?: number): void {
index: number, name: string, attrsIndex?: number|null, localRefsIndex?: number): void {
ɵɵelementStart(index, name, attrsIndex, localRefsIndex);
ɵɵelementEnd();
}
@ -198,11 +200,11 @@ function warnAboutUnknownElement(
if (isUnknown && !matchingSchemas(tView, lView, tagName)) {
let warning = `'${tagName}' is not a known element:\n`;
warning +=
`1. If '${tagName}' is an Angular component, then verify that it is part of this module.\n`;
warning += `1. If '${
tagName}' is an Angular component, then verify that it is part of this module.\n`;
if (tagName && tagName.indexOf('-') > -1) {
warning +=
`2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.`;
warning += `2. If '${
tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.`;
} else {
warning +=
`2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.`;

View File

@ -11,7 +11,7 @@ import {attachPatchData} from '../context_discovery';
import {registerPostOrderHooks} from '../hooks';
import {TAttributes, TElementContainerNode, TNodeType} from '../interfaces/node';
import {isContentQueryHost, isDirectiveHost} from '../interfaces/type_checks';
import {HEADER_OFFSET, LView, RENDERER, TView, T_HOST} from '../interfaces/view';
import {HEADER_OFFSET, LView, RENDERER, T_HOST, TView} from '../interfaces/view';
import {assertNodeType} from '../node_assert';
import {appendChild} from '../node_manipulation';
import {getBindingIndex, getIsParent, getLView, getPreviousOrParentTNode, getTView, setIsNotParent, setPreviousOrParentTNode} from '../state';
@ -21,7 +21,7 @@ import {getConstant} from '../util/view_utils';
import {createDirectivesInstances, executeContentQueries, getOrCreateTNode, resolveDirectives, saveResolvedLocalsInData} from './shared';
function elementContainerStartFirstCreatePass(
index: number, tView: TView, lView: LView, attrsIndex?: number | null,
index: number, tView: TView, lView: LView, attrsIndex?: number|null,
localRefsIndex?: number): TElementContainerNode {
ngDevMode && ngDevMode.firstCreatePass++;
@ -61,15 +61,16 @@ function elementContainerStartFirstCreatePass(
* @codeGenApi
*/
export function ɵɵelementContainerStart(
index: number, attrsIndex?: number | null, localRefsIndex?: number): void {
index: number, attrsIndex?: number|null, localRefsIndex?: number): void {
const lView = getLView();
const tView = getTView();
const adjustedIndex = index + HEADER_OFFSET;
ngDevMode && assertDataInRange(lView, adjustedIndex);
ngDevMode && assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'element containers should be created before any bindings');
ngDevMode &&
assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'element containers should be created before any bindings');
const tNode = tView.firstCreatePass ?
elementContainerStartFirstCreatePass(index, tView, lView, attrsIndex, localRefsIndex) :
@ -104,7 +105,7 @@ export function ɵɵelementContainerEnd(): void {
setIsNotParent();
} else {
ngDevMode && assertHasParent(previousOrParentTNode);
previousOrParentTNode = previousOrParentTNode.parent !;
previousOrParentTNode = previousOrParentTNode.parent!;
setPreviousOrParentTNode(previousOrParentTNode, false);
}
@ -113,7 +114,7 @@ export function ɵɵelementContainerEnd(): void {
if (tView.firstCreatePass) {
registerPostOrderHooks(tView, previousOrParentTNode);
if (isContentQueryHost(previousOrParentTNode)) {
tView.queries !.elementEnd(previousOrParentTNode);
tView.queries!.elementEnd(previousOrParentTNode);
}
}
}
@ -129,7 +130,7 @@ export function ɵɵelementContainerEnd(): void {
* @codeGenApi
*/
export function ɵɵelementContainer(
index: number, attrsIndex?: number | null, localRefsIndex?: number): void {
index: number, attrsIndex?: number|null, localRefsIndex?: number): void {
ɵɵelementContainerStart(index, attrsIndex, localRefsIndex);
ɵɵelementContainerEnd();
}

View File

@ -11,7 +11,7 @@ import {assertLContainerOrUndefined} from '../assert';
import {ACTIVE_INDEX, ActiveIndexFlag, CONTAINER_HEADER_OFFSET, LContainer} from '../interfaces/container';
import {RenderFlags} from '../interfaces/definition';
import {TContainerNode, TNodeType} from '../interfaces/node';
import {CONTEXT, LView, LViewFlags, PARENT, TVIEW, TView, TViewType, T_HOST} from '../interfaces/view';
import {CONTEXT, LView, LViewFlags, PARENT, T_HOST, TVIEW, TView, TViewType} from '../interfaces/view';
import {assertNodeType} from '../node_assert';
import {insertView, removeView} from '../node_manipulation';
import {enterView, getIsParent, getLView, getPreviousOrParentTNode, getTView, leaveView, setIsParent, setPreviousOrParentTNode} from '../state';
@ -34,7 +34,7 @@ export function ɵɵembeddedViewStart(viewBlockId: number, decls: number, vars:
const previousOrParentTNode = getPreviousOrParentTNode();
// The previous node can be a view node if we are processing an inline for loop
const containerTNode = previousOrParentTNode.type === TNodeType.View ?
previousOrParentTNode.parent ! :
previousOrParentTNode.parent! :
previousOrParentTNode;
const lContainer = lView[containerTNode.index] as LContainer;
@ -141,5 +141,5 @@ export function ɵɵembeddedViewEnd(): void {
const lContainer = lView[PARENT] as LContainer;
ngDevMode && assertLContainerOrUndefined(lContainer);
leaveView();
setPreviousOrParentTNode(viewHost !, false);
setPreviousOrParentTNode(viewHost!, false);
}

View File

@ -28,7 +28,7 @@ import {elementPropertyInternal, loadComponentRenderer, storePropertyBindingMeta
* @codeGenApi
*/
export function ɵɵhostProperty<T>(
propName: string, value: T, sanitizer?: SanitizerFn | null): typeof ɵɵhostProperty {
propName: string, value: T, sanitizer?: SanitizerFn|null): typeof ɵɵhostProperty {
const lView = getLView();
const bindingIndex = nextBindingIndex();
if (bindingUpdated(lView, bindingIndex, value)) {
@ -63,8 +63,8 @@ export function ɵɵhostProperty<T>(
* @codeGenApi
*/
export function ɵɵupdateSyntheticHostBinding<T>(
propName: string, value: T | NO_CHANGE,
sanitizer?: SanitizerFn | null): typeof ɵɵupdateSyntheticHostBinding {
propName: string, value: T|NO_CHANGE,
sanitizer?: SanitizerFn|null): typeof ɵɵupdateSyntheticHostBinding {
const lView = getLView();
const bindingIndex = nextBindingIndex();
if (bindingUpdated(lView, bindingIndex, value)) {

View File

@ -102,10 +102,9 @@ export function interpolation4(
const different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
incrementBindingIndex(4);
return different ?
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
renderStringify(v3) + suffix :
NO_CHANGE;
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
renderStringify(v2) + i2 + renderStringify(v3) + suffix :
NO_CHANGE;
}
/**
@ -119,10 +118,9 @@ export function interpolation5(
different = bindingUpdated(lView, bindingIndex + 4, v4) || different;
incrementBindingIndex(5);
return different ?
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
renderStringify(v3) + i3 + renderStringify(v4) + suffix :
NO_CHANGE;
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + suffix :
NO_CHANGE;
}
/**
@ -154,11 +152,10 @@ export function interpolation7(
different = bindingUpdated3(lView, bindingIndex + 4, v4, v5, v6) || different;
incrementBindingIndex(7);
return different ?
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + i5 +
renderStringify(v6) + suffix :
NO_CHANGE;
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
renderStringify(v5) + i5 + renderStringify(v6) + suffix :
NO_CHANGE;
}
/**
@ -173,9 +170,8 @@ export function interpolation8(
different = bindingUpdated4(lView, bindingIndex + 4, v4, v5, v6, v7) || different;
incrementBindingIndex(8);
return different ?
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + i5 +
renderStringify(v6) + i6 + renderStringify(v7) + suffix :
NO_CHANGE;
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
renderStringify(v5) + i5 + renderStringify(v6) + i6 + renderStringify(v7) + suffix :
NO_CHANGE;
}

View File

@ -11,12 +11,13 @@ import {assertDataInRange} from '../../util/assert';
import {isObservable} from '../../util/lang';
import {EMPTY_OBJ} from '../empty';
import {PropertyAliasValue, TNode, TNodeFlags, TNodeType} from '../interfaces/node';
import {GlobalTargetResolver, RElement, Renderer3, isProceduralRenderer} from '../interfaces/renderer';
import {GlobalTargetResolver, isProceduralRenderer, RElement, Renderer3} from '../interfaces/renderer';
import {isDirectiveHost} from '../interfaces/type_checks';
import {CLEANUP, FLAGS, LView, LViewFlags, RENDERER, TView} from '../interfaces/view';
import {assertNodeOfPossibleTypes} from '../node_assert';
import {getLView, getPreviousOrParentTNode, getTView} from '../state';
import {getComponentLViewByIndex, getNativeByTNode, unwrapRNode} from '../util/view_utils';
import {getLCleanup, handleError, loadComponentRenderer, markViewDirty} from './shared';
@ -47,26 +48,26 @@ export function ɵɵlistener(
}
/**
* Registers a synthetic host listener (e.g. `(@foo.start)`) on a component.
*
* This instruction is for compatibility purposes and is designed to ensure that a
* synthetic host listener (e.g. `@HostListener('@foo.start')`) properly gets rendered
* in the component's renderer. Normally all host listeners are evaluated with the
* parent component's renderer, but, in the case of animation @triggers, they need
* to be evaluated with the sub component's renderer (because that's where the
* animation triggers are defined).
*
* Do not use this instruction as a replacement for `listener`. This instruction
* only exists to ensure compatibility with the ViewEngine's host binding behavior.
*
* @param eventName Name of the event
* @param listenerFn The function to be called when event emits
* @param useCapture Whether or not to use capture in event listener
* @param eventTargetResolver Function that returns global target information in case this listener
* should be attached to a global object like window, document or body
* Registers a synthetic host listener (e.g. `(@foo.start)`) on a component.
*
* This instruction is for compatibility purposes and is designed to ensure that a
* synthetic host listener (e.g. `@HostListener('@foo.start')`) properly gets rendered
* in the component's renderer. Normally all host listeners are evaluated with the
* parent component's renderer, but, in the case of animation @triggers, they need
* to be evaluated with the sub component's renderer (because that's where the
* animation triggers are defined).
*
* Do not use this instruction as a replacement for `listener`. This instruction
* only exists to ensure compatibility with the ViewEngine's host binding behavior.
*
* @param eventName Name of the event
* @param listenerFn The function to be called when event emits
* @param useCapture Whether or not to use capture in event listener
* @param eventTargetResolver Function that returns global target information in case this listener
* should be attached to a global object like window, document or body
*
* @codeGenApi
*/
*/
export function ɵɵcomponentHostSyntheticListener(
eventName: string, listenerFn: (e?: any) => any, useCapture = false,
eventTargetResolver?: GlobalTargetResolver): typeof ɵɵcomponentHostSyntheticListener {
@ -94,7 +95,7 @@ function findExistingListener(
// We have found a matching event name on the same node but it might not have been
// registered yet, so we must explicitly verify entries in the LView cleanup data
// structures.
const lCleanup = lView[CLEANUP] !;
const lCleanup = lView[CLEANUP]!;
const listenerIdxInLCleanup = tCleanup[i + 2];
return lCleanup.length > listenerIdxInLCleanup ? lCleanup[listenerIdxInLCleanup] : null;
}
@ -124,8 +125,9 @@ function listenerInternal(
// register a listener and store its cleanup function on LView.
const lCleanup = getLCleanup(lView);
ngDevMode && assertNodeOfPossibleTypes(
tNode, TNodeType.Element, TNodeType.Container, TNodeType.ElementContainer);
ngDevMode &&
assertNodeOfPossibleTypes(
tNode, TNodeType.Element, TNodeType.Container, TNodeType.ElementContainer);
let processOutputs = true;
@ -207,8 +209,8 @@ function listenerInternal(
const output = directiveInstance[minifiedName];
if (ngDevMode && !isObservable(output)) {
throw new Error(
`@Output ${minifiedName} not initialized in '${directiveInstance.constructor.name}'.`);
throw new Error(`@Output ${minifiedName} not initialized in '${
directiveInstance.constructor.name}'.`);
}
const subscription = output.subscribe(listenerFn);

View File

@ -79,9 +79,9 @@ export function ɵɵprojectionDef(projectionSlots?: ProjectionSlots): void {
// If no explicit projection slots are defined, fall back to a single
// projection slot with the wildcard selector.
const numProjectionSlots = projectionSlots ? projectionSlots.length : 1;
const projectionHeads: (TNode | null)[] = componentNode.projection =
newArray(numProjectionSlots, null !as TNode);
const tails: (TNode | null)[] = projectionHeads.slice();
const projectionHeads: (TNode|null)[] = componentNode.projection =
newArray(numProjectionSlots, null! as TNode);
const tails: (TNode|null)[] = projectionHeads.slice();
let componentChild: TNode|null = componentNode.child;
@ -91,7 +91,7 @@ export function ɵɵprojectionDef(projectionSlots?: ProjectionSlots): void {
if (slotIndex !== null) {
if (tails[slotIndex]) {
tails[slotIndex] !.projectionNext = componentChild;
tails[slotIndex]!.projectionNext = componentChild;
} else {
projectionHeads[slotIndex] = componentChild;
}
@ -119,7 +119,7 @@ export function setDelayProjection(value: boolean) {
* - 1 based index of the selector from the {@link projectionDef}
*
* @codeGenApi
*/
*/
export function ɵɵprojection(
nodeIndex: number, selectorIndex: number = 0, attrs?: TAttributes): void {
const lView = getLView();

View File

@ -33,7 +33,7 @@ import {elementPropertyInternal, setInputsForProperty, storePropertyBindingMetad
* @codeGenApi
*/
export function ɵɵproperty<T>(
propName: string, value: T, sanitizer?: SanitizerFn | null): typeof ɵɵproperty {
propName: string, value: T, sanitizer?: SanitizerFn|null): typeof ɵɵproperty {
const lView = getLView();
const bindingIndex = nextBindingIndex();
if (bindingUpdated(lView, bindingIndex, value)) {
@ -52,7 +52,7 @@ export function ɵɵproperty<T>(
*/
export function setDirectiveInputsWhichShadowsStyling(
tView: TView, tNode: TNode, lView: LView, value: any, isClassBased: boolean) {
const inputs = tNode.inputs !;
const inputs = tNode.inputs!;
const property = isClassBased ? 'class' : 'style';
// We support both 'class' and `className` hence the fallback.
setInputsForProperty(tView, lView, inputs[property], property, value);

View File

@ -88,8 +88,9 @@ export function ɵɵpropertyInterpolate1(
const tNode = getSelectedTNode();
elementPropertyInternal(
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
ngDevMode && storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 1, prefix, suffix);
ngDevMode &&
storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 1, prefix, suffix);
}
return ɵɵpropertyInterpolate1;
}
@ -134,8 +135,9 @@ export function ɵɵpropertyInterpolate2(
const tNode = getSelectedTNode();
elementPropertyInternal(
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
ngDevMode && storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 2, prefix, i0, suffix);
ngDevMode &&
storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 2, prefix, i0, suffix);
}
return ɵɵpropertyInterpolate2;
}
@ -183,8 +185,9 @@ export function ɵɵpropertyInterpolate3(
const tNode = getSelectedTNode();
elementPropertyInternal(
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
ngDevMode && storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 3, prefix, i0, i1, suffix);
ngDevMode &&
storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 3, prefix, i0, i1, suffix);
}
return ɵɵpropertyInterpolate3;
}
@ -408,9 +411,10 @@ export function ɵɵpropertyInterpolate7(
const tNode = getSelectedTNode();
elementPropertyInternal(
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
ngDevMode && storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 7, prefix, i0, i1, i2, i3, i4,
i5, suffix);
ngDevMode &&
storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 7, prefix, i0, i1, i2, i3, i4, i5,
suffix);
}
return ɵɵpropertyInterpolate7;
}
@ -470,9 +474,10 @@ export function ɵɵpropertyInterpolate8(
const tNode = getSelectedTNode();
elementPropertyInternal(
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
ngDevMode && storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 8, prefix, i0, i1, i2, i3, i4,
i5, i6, suffix);
ngDevMode &&
storePropertyBindingMetadata(
tView.data, tNode, propName, getBindingIndex() - 8, prefix, i0, i1, i2, i3, i4, i5, i6,
suffix);
}
return ɵɵpropertyInterpolate8;
}

View File

@ -39,7 +39,7 @@ import {checkStylingProperty} from './styling';
*/
export function ɵɵstylePropInterpolate1(
prop: string, prefix: string, v0: any, suffix: string,
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate1 {
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate1 {
const lView = getLView();
const interpolatedValue = interpolation1(lView, prefix, v0, suffix);
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);
@ -76,7 +76,7 @@ export function ɵɵstylePropInterpolate1(
*/
export function ɵɵstylePropInterpolate2(
prop: string, prefix: string, v0: any, i0: string, v1: any, suffix: string,
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate2 {
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate2 {
const lView = getLView();
const interpolatedValue = interpolation2(lView, prefix, v0, i0, v1, suffix);
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);
@ -115,7 +115,7 @@ export function ɵɵstylePropInterpolate2(
*/
export function ɵɵstylePropInterpolate3(
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, suffix: string,
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate3 {
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate3 {
const lView = getLView();
const interpolatedValue = interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix);
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);
@ -156,7 +156,7 @@ export function ɵɵstylePropInterpolate3(
*/
export function ɵɵstylePropInterpolate4(
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
v3: any, suffix: string, valueSuffix?: string | null): typeof ɵɵstylePropInterpolate4 {
v3: any, suffix: string, valueSuffix?: string|null): typeof ɵɵstylePropInterpolate4 {
const lView = getLView();
const interpolatedValue = interpolation4(lView, prefix, v0, i0, v1, i1, v2, i2, v3, suffix);
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);
@ -200,7 +200,7 @@ export function ɵɵstylePropInterpolate4(
export function ɵɵstylePropInterpolate5(
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
v3: any, i3: string, v4: any, suffix: string,
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate5 {
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate5 {
const lView = getLView();
const interpolatedValue =
interpolation5(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix);
@ -247,7 +247,7 @@ export function ɵɵstylePropInterpolate5(
export function ɵɵstylePropInterpolate6(
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
v3: any, i3: string, v4: any, i4: string, v5: any, suffix: string,
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate6 {
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate6 {
const lView = getLView();
const interpolatedValue =
interpolation6(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix);
@ -297,7 +297,7 @@ export function ɵɵstylePropInterpolate6(
export function ɵɵstylePropInterpolate7(
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
v3: any, i3: string, v4: any, i4: string, v5: any, i5: string, v6: any, suffix: string,
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate7 {
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate7 {
const lView = getLView();
const interpolatedValue =
interpolation7(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix);
@ -349,7 +349,7 @@ export function ɵɵstylePropInterpolate7(
export function ɵɵstylePropInterpolate8(
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
v3: any, i3: string, v4: any, i4: string, v5: any, i5: string, v6: any, i6: string, v7: any,
suffix: string, valueSuffix?: string | null): typeof ɵɵstylePropInterpolate8 {
suffix: string, valueSuffix?: string|null): typeof ɵɵstylePropInterpolate8 {
const lView = getLView();
const interpolatedValue = interpolation8(
lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix);
@ -388,7 +388,7 @@ export function ɵɵstylePropInterpolate8(
* @codeGenApi
*/
export function ɵɵstylePropInterpolateV(
prop: string, values: any[], valueSuffix?: string | null): typeof ɵɵstylePropInterpolateV {
prop: string, values: any[], valueSuffix?: string|null): typeof ɵɵstylePropInterpolateV {
const lView = getLView();
const interpolatedValue = interpolationV(lView, values);
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);

View File

@ -1,10 +1,10 @@
/**
* @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
*/
* @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 {SafeValue, unwrapSafeValue} from '../../sanitization/bypass';
import {stylePropNeedsSanitization, ɵɵsanitizeStyle} from '../../sanitization/sanitization';
@ -19,7 +19,7 @@ import {DirectiveDef} from '../interfaces/definition';
import {AttributeMarker, TAttributes, TNode, TNodeFlags, TNodeType} from '../interfaces/node';
import {RElement, Renderer3} from '../interfaces/renderer';
import {SanitizerFn} from '../interfaces/sanitization';
import {TStylingKey, TStylingRange, getTStylingRangeNext, getTStylingRangeNextDuplicate, getTStylingRangePrev, getTStylingRangePrevDuplicate} from '../interfaces/styling';
import {getTStylingRangeNext, getTStylingRangeNextDuplicate, getTStylingRangePrev, getTStylingRangePrevDuplicate, TStylingKey, TStylingRange} from '../interfaces/styling';
import {HEADER_OFFSET, LView, RENDERER, TData, TView} from '../interfaces/view';
import {applyStyling} from '../node_manipulation';
import {getCurrentDirectiveIndex, getCurrentStyleSanitizer, getLView, getSelectedIndex, getTView, incrementBindingIndex, setCurrentStyleSanitizer} from '../state';
@ -27,6 +27,7 @@ import {insertTStylingBinding} from '../styling/style_binding_list';
import {getLastParsedKey, getLastParsedValue, parseClassName, parseClassNameNext, parseStyle, parseStyleNext} from '../styling/styling_parser';
import {NO_CHANGE} from '../tokens';
import {getNativeByIndex} from '../util/view_utils';
import {setDirectiveInputsWhichShadowsStyling} from './property';
@ -46,7 +47,7 @@ import {setDirectiveInputsWhichShadowsStyling} from './property';
*
* @codeGenApi
*/
export function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn | null): void {
export function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn|null): void {
setCurrentStyleSanitizer(sanitizer);
}
@ -72,8 +73,8 @@ export function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn | null): void {
* @codeGenApi
*/
export function ɵɵstyleProp(
prop: string, value: string | number | SafeValue | undefined | null,
suffix?: string | null): typeof ɵɵstyleProp {
prop: string, value: string|number|SafeValue|undefined|null,
suffix?: string|null): typeof ɵɵstyleProp {
checkStylingProperty(prop, value, suffix, false);
return ɵɵstyleProp;
}
@ -93,8 +94,7 @@ export function ɵɵstyleProp(
*
* @codeGenApi
*/
export function ɵɵclassProp(
className: string, value: boolean | undefined | null): typeof ɵɵclassProp {
export function ɵɵclassProp(className: string, value: boolean|undefined|null): typeof ɵɵclassProp {
checkStylingProperty(className, value, null, true);
return ɵɵclassProp;
}
@ -119,7 +119,7 @@ export function ɵɵclassProp(
*
* @codeGenApi
*/
export function ɵɵstyleMap(styles: {[styleName: string]: any} | string | undefined | null): void {
export function ɵɵstyleMap(styles: {[styleName: string]: any}|string|undefined|null): void {
checkStylingMap(styleKeyValueArraySet, styleStringParser, styles, false);
}
@ -158,8 +158,8 @@ export function styleStringParser(keyValueArray: KeyValueArray<any>, text: strin
*
* @codeGenApi
*/
export function ɵɵclassMap(
classes: {[className: string]: boolean | undefined | null} | string | undefined | null): void {
export function ɵɵclassMap(classes: {[className: string]: boolean|undefined|null}|string|undefined|
null): void {
checkStylingMap(keyValueArraySet, classStringParser, classes, true);
}
@ -187,8 +187,8 @@ export function classStringParser(keyValueArray: KeyValueArray<any>, text: strin
* @param isClassBased `true` if `class` change (`false` if `style`)
*/
export function checkStylingProperty(
prop: string, value: any | NO_CHANGE,
suffixOrSanitizer: SanitizerFn | string | undefined | null, isClassBased: boolean): void {
prop: string, value: any|NO_CHANGE, suffixOrSanitizer: SanitizerFn|string|undefined|null,
isClassBased: boolean): void {
const lView = getLView();
const tView = getTView();
// Styling instructions use 2 slots per binding.
@ -289,14 +289,14 @@ function isInHostBindings(tView: TView, bindingIndex: number): boolean {
}
/**
* Collects the necessary information to insert the binding into a linked list of style bindings
* using `insertTStylingBinding`.
*
* @param tView `TView` where the binding linked list will be stored.
* @param tStylingKey Property/key of the binding.
* @param bindingIndex Index of binding associated with the `prop`
* @param isClassBased `true` if `class` change (`false` if `style`)
*/
* Collects the necessary information to insert the binding into a linked list of style bindings
* using `insertTStylingBinding`.
*
* @param tView `TView` where the binding linked list will be stored.
* @param tStylingKey Property/key of the binding.
* @param bindingIndex Index of binding associated with the `prop`
* @param isClassBased `true` if `class` change (`false` if `style`)
*/
function stylingFirstUpdatePass(
tView: TView, tStylingKey: TStylingKey, bindingIndex: number, isClassBased: boolean): void {
ngDevMode && assertFirstUpdatePass(tView);
@ -477,9 +477,10 @@ function getTemplateHeadTStylingKey(tData: TData, tNode: TNode, isClassBased: bo
function setTemplateHeadTStylingKey(
tData: TData, tNode: TNode, isClassBased: boolean, tStylingKey: TStylingKey): void {
const bindings = isClassBased ? tNode.classBindings : tNode.styleBindings;
ngDevMode && assertNotEqual(
getTStylingRangeNext(bindings), 0,
'Expecting to have at least one template styling binding.');
ngDevMode &&
assertNotEqual(
getTStylingRangeNext(bindings), 0,
'Expecting to have at least one template styling binding.');
tData[getTStylingRangePrev(bindings)] = tStylingKey;
}
@ -523,7 +524,7 @@ function collectResidual(tData: TData, tNode: TNode, isClassBased: boolean): Key
* @param isClassBased `true` if `class` (`false` if `style`)
*/
function collectStylingFromDirectives(
hostDirectiveDef: DirectiveDef<any>| null, tData: TData, tNode: TNode, stylingKey: TStylingKey,
hostDirectiveDef: DirectiveDef<any>|null, tData: TData, tNode: TNode, stylingKey: TStylingKey,
isClassBased: boolean): TStylingKey {
// We need to loop because there can be directives which have `hostAttrs` but don't have
// `hostBindings` so this loop catches up to the current directive..
@ -559,7 +560,7 @@ function collectStylingFromDirectives(
* @param isClassBased `true` if `class` (`false` if `style`)
*/
function collectStylingFromTAttrs(
stylingKey: TStylingKey | undefined, attrs: TAttributes | null,
stylingKey: TStylingKey|undefined, attrs: TAttributes|null,
isClassBased: boolean): TStylingKey {
const desiredMarker = isClassBased ? AttributeMarker.Classes : AttributeMarker.Styles;
let currentMarker = AttributeMarker.ImplicitAttributes;
@ -711,7 +712,7 @@ function updateStylingMap(
setKey = newKey;
setValue = newValue;
}
} else if (newKey === null || oldKey !== null && oldKey < newKey !) {
} else if (newKey === null || oldKey !== null && oldKey < newKey!) {
// DELETE: oldKey key is missing or we did not find the oldKey in the newValue
// (because the keyValueArray is sorted and `newKey` is found later alphabetically).
// `"background" < "color"` so we need to delete `"background"` because it is not found in the
@ -754,7 +755,7 @@ function updateStylingMap(
*/
function updateStyling(
tView: TView, tNode: TNode, lView: LView, renderer: Renderer3, prop: string,
value: string | undefined | null | boolean, isClassBased: boolean, bindingIndex: number) {
value: string|undefined|null|boolean, isClassBased: boolean, bindingIndex: number) {
if (tNode.type !== TNodeType.Element) {
// It is possible to have styling on non-elements (such as ng-container).
// This is rare, but it does happen. In such a case, just ignore the binding.
@ -811,7 +812,7 @@ function updateStyling(
* @param isClassBased `true` if `class` (`false` if `style`)
*/
function findStylingValue(
tData: TData, tNode: TNode | null, lView: LView, prop: string, index: number,
tData: TData, tNode: TNode|null, lView: LView, prop: string, index: number,
isClassBased: boolean): any {
// `TNode` to use for resolving static styling. Also controls search direction.
// - `TNode` search next and quit as soon as `isStylingValuePresent(value)` is true.
@ -856,7 +857,7 @@ function findStylingValue(
// consult residual styling
let residual = isClassBased ? tNode.residualClasses : tNode.residualStyles;
if (residual != null /** OR residual !=== undefined */) {
value = keyValueArrayGet(residual !, prop);
value = keyValueArrayGet(residual!, prop);
}
}
return value;
@ -884,7 +885,7 @@ function isStylingValuePresent(value: any): boolean {
* @param suffixOrSanitizer
*/
function normalizeAndApplySuffixOrSanitizer(
value: any, suffixOrSanitizer: SanitizerFn | string | undefined | null): string|null|undefined|
value: any, suffixOrSanitizer: SanitizerFn|string|undefined|null): string|null|undefined|
boolean {
if (value == null /** || value === undefined */) {
// do nothing

View File

@ -27,9 +27,10 @@ export function ɵɵtext(index: number, value: string = ''): void {
const tView = getTView();
const adjustedIndex = index + HEADER_OFFSET;
ngDevMode && assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'text nodes should be created before any bindings');
ngDevMode &&
assertEqual(
getBindingIndex(), tView.bindingStartIndex,
'text nodes should be created before any bindings');
ngDevMode && assertDataInRange(lView, adjustedIndex);
const tNode = tView.firstCreatePass ?

View File

@ -22,7 +22,7 @@ export type ComponentTemplate<T> = {
// Note: the ctx parameter is typed as T|U, as using only U would prevent a template with
// e.g. ctx: {} from being assigned to ComponentTemplate<any> as TypeScript won't infer U = any
// in that scenario. By including T this incompatibility is resolved.
<U extends T>(rf: RenderFlags, ctx: T | U): void;
<U extends T>(rf: RenderFlags, ctx: T|U): void;
};
/**
@ -72,7 +72,9 @@ export const enum RenderFlags {
* A subclass of `Type` which has a static `ɵcmp`:`ComponentDef` field making it
* consumable for rendering.
*/
export interface ComponentType<T> extends Type<T> { ɵcmp: never; }
export interface ComponentType<T> extends Type<T> {
ɵcmp: never;
}
/**
* A subclass of `Type` which has a static `ɵdir`:`DirectiveDef` field making it
@ -87,7 +89,9 @@ export interface DirectiveType<T> extends Type<T> {
* A subclass of `Type` which has a static `ɵpipe`:`PipeDef` field making it
* consumable for rendering.
*/
export interface PipeType<T> extends Type<T> { ɵpipe: never; }
export interface PipeType<T> extends Type<T> {
ɵpipe: never;
}
/**
* An object literal of this type is used to represent the metadata of a constructor dependency.
@ -99,7 +103,7 @@ export type CtorDependency = {
* attribute name is a dynamic expression instead of a string literal, this will be the unknown
* type.
*/
attribute?: string | unknown;
attribute?: string|unknown;
/**
* If `@Optional()` is used, this key is set to true.
@ -120,14 +124,17 @@ export type CtorDependency = {
* If `@SkipSelf` is used, this key is set to true.
*/
skipSelf?: true;
} | null;
}|null;
/**
* @codeGenApi
*/
export type ɵɵDirectiveDefWithMeta<
T, Selector extends string, ExportAs extends string[], InputMap extends{[key: string]: string},
OutputMap extends{[key: string]: string}, QueryFields extends string[]> = DirectiveDef<T>;
T, Selector extends string, ExportAs extends
string[], InputMap extends {[key: string]: string},
OutputMap extends {[key: string]: string},
QueryFields extends string[]> =
DirectiveDef<T>;
/**
* Runtime link information for Directives.
@ -268,9 +275,10 @@ export interface DirectiveDef<T> {
* @codeGenApi
*/
export type ɵɵComponentDefWithMeta<
T, Selector extends String, ExportAs extends string[], InputMap extends{[key: string]: string},
OutputMap extends{[key: string]: string}, QueryFields extends string[],
NgContentSelectors extends string[]> = ComponentDef<T>;
T, Selector extends String, ExportAs extends
string[], InputMap extends {[key: string]: string},
OutputMap extends {[key: string]: string}, QueryFields extends
string[], NgContentSelectors extends string[]> = ComponentDef<T>;
/**
* @codeGenApi
@ -467,14 +475,14 @@ export interface ComponentDefFeature {
*
* The function is necessary to be able to support forward declarations.
*/
export type DirectiveDefListOrFactory = (() => DirectiveDefList) | DirectiveDefList;
export type DirectiveDefListOrFactory = (() => DirectiveDefList)|DirectiveDefList;
export type DirectiveDefList = (DirectiveDef<any>| ComponentDef<any>)[];
export type DirectiveDefList = (DirectiveDef<any>|ComponentDef<any>)[];
export type DirectiveTypesOrFactory = (() => DirectiveTypeList) | DirectiveTypeList;
export type DirectiveTypesOrFactory = (() => DirectiveTypeList)|DirectiveTypeList;
export type DirectiveTypeList =
(DirectiveType<any>| ComponentType<any>|
(DirectiveType<any>|ComponentType<any>|
Type<any>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[];
export type HostBindingsFunction<T> = <U extends T>(rf: RenderFlags, ctx: U) => void;
@ -484,14 +492,14 @@ export type HostBindingsFunction<T> = <U extends T>(rf: RenderFlags, ctx: U) =>
*
* The function is necessary to be able to support forward declarations.
*/
export type PipeDefListOrFactory = (() => PipeDefList) | PipeDefList;
export type PipeDefListOrFactory = (() => PipeDefList)|PipeDefList;
export type PipeDefList = PipeDef<any>[];
export type PipeTypesOrFactory = (() => PipeTypeList) | PipeTypeList;
export type PipeTypesOrFactory = (() => PipeTypeList)|PipeTypeList;
export type PipeTypeList =
(PipeType<any>| Type<any>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[];
(PipeType<any>|Type<any>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[];
// Note: This hack is necessary so we don't erroneously get a circular dependency

View File

@ -31,7 +31,7 @@ let DOCUMENT: Document|undefined = undefined;
*
* @param document The object representing the global `document` in this environment.
*/
export function setDocument(document: Document | undefined): void {
export function setDocument(document: Document|undefined): void {
DOCUMENT = document;
}
@ -52,5 +52,5 @@ export function getDocument(): Document {
// this should not happen in Angular apps.
// Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
// public API. Meanwhile we just return `undefined` and let the application fail.
return undefined !;
return undefined!;
}

View File

@ -66,7 +66,9 @@ export const enum I18nMutateOpCode {
export const ELEMENT_MARKER: ELEMENT_MARKER = {
marker: 'element'
};
export interface ELEMENT_MARKER { marker: 'element'; }
export interface ELEMENT_MARKER {
marker: 'element';
}
/**
* Marks that the next string is for comment.
@ -77,7 +79,9 @@ export const COMMENT_MARKER: COMMENT_MARKER = {
marker: 'comment'
};
export interface COMMENT_MARKER { marker: 'comment'; }
export interface COMMENT_MARKER {
marker: 'comment';
}
/**
* Array storing OpCode for dynamically creating `i18n` blocks.

View File

@ -23,7 +23,9 @@ export const INJECTOR_BLOOM_PARENT_SIZE = 9;
* The interfaces encodes number of parents `LView`s to traverse and index in the `LView`
* pointing to the parent injector.
*/
export interface RelativeInjectorLocation { __brand__: 'RelativeInjectorLocationFlags'; }
export interface RelativeInjectorLocation {
__brand__: 'RelativeInjectorLocationFlags';
}
export const enum RelativeInjectorLocationFlags {
InjectorIndexMask = 0b111111111111111,
@ -114,20 +116,20 @@ export const NO_PARENT_INJECTOR: RelativeInjectorLocation = -1 as any;
*/
/**
* Factory for creating instances of injectors in the NodeInjector.
*
* This factory is complicated by the fact that it can resolve `multi` factories as well.
*
* NOTE: Some of the fields are optional which means that this class has two hidden classes.
* - One without `multi` support (most common)
* - One with `multi` values, (rare).
*
* Since VMs can cache up to 4 inline hidden classes this is OK.
*
* - Single factory: Only `resolving` and `factory` is defined.
* - `providers` factory: `componentProviders` is a number and `index = -1`.
* - `viewProviders` factory: `componentProviders` is a number and `index` points to `providers`.
*/
* Factory for creating instances of injectors in the NodeInjector.
*
* This factory is complicated by the fact that it can resolve `multi` factories as well.
*
* NOTE: Some of the fields are optional which means that this class has two hidden classes.
* - One without `multi` support (most common)
* - One with `multi` values, (rare).
*
* Since VMs can cache up to 4 inline hidden classes this is OK.
*
* - Single factory: Only `resolving` and `factory` is defined.
* - `providers` factory: `componentProviders` is a number and `index = -1`.
* - `viewProviders` factory: `componentProviders` is a number and `index` points to `providers`.
*/
export class NodeInjectorFactory {
/**
* The inject implementation to be activated when using the factory.
@ -234,7 +236,8 @@ export class NodeInjectorFactory {
/**
* Set to `true` if the token is declared in `viewProviders` (or if it is component).
*/
isViewProvider: boolean, injectImplementation: null|
isViewProvider: boolean,
injectImplementation: null|
(<T>(token: Type<T>|InjectionToken<T>, flags?: InjectFlags) => T)) {
this.canSeeViewProviders = isViewProvider;
this.injectImpl = injectImplementation;

View File

@ -90,8 +90,10 @@ export const enum TNodeProviderIndexes {
/** The index of the first provider on this node is encoded on the least significant bits */
ProvidersStartIndexMask = 0b00000000000000001111111111111111,
/** The count of view providers from the component on this node is encoded on the 16 most
significant bits */
/**
The count of view providers from the component on this node is encoded on the 16 most
significant bits
*/
CptViewProvidersCountShift = 16,
CptViewProvidersCountShifter = 0b00000000000000010000000000000000,
}
@ -117,21 +119,21 @@ export const enum AttributeMarker {
NamespaceURI = 0,
/**
* Signals class declaration.
*
* Each value following `Classes` designates a class name to include on the element.
* ## Example:
*
* Given:
* ```
* <div class="foo bar baz">...<d/vi>
* ```
*
* the generated code is:
* ```
* var _c1 = [AttributeMarker.Classes, 'foo', 'bar', 'baz'];
* ```
*/
* Signals class declaration.
*
* Each value following `Classes` designates a class name to include on the element.
* ## Example:
*
* Given:
* ```
* <div class="foo bar baz">...<d/vi>
* ```
*
* the generated code is:
* ```
* var _c1 = [AttributeMarker.Classes, 'foo', 'bar', 'baz'];
* ```
*/
Classes = 1,
/**
@ -235,14 +237,14 @@ export const enum AttributeMarker {
* - Special markers acting as flags to alter attributes processing.
* - Parsed ngProjectAs selectors.
*/
export type TAttributes = (string | AttributeMarker | CssSelector)[];
export type TAttributes = (string|AttributeMarker|CssSelector)[];
/**
* Constants that are associated with a view. Includes:
* - Attribute arrays.
* - Local definition arrays.
*/
export type TConstants = (TAttributes | string)[];
export type TConstants = (TAttributes|string)[];
/**
* Binding data (flyweight) for a particular node that is shared between all templates
@ -700,7 +702,7 @@ export interface TProjectionNode extends TNode {
/**
* A union type representing all TNode types that can host a directive.
*/
export type TDirectiveHostNode = TElementNode | TContainerNode | TElementContainerNode;
export type TDirectiveHostNode = TElementNode|TContainerNode|TElementContainerNode;
/**
* This mapping is necessary so we can set input properties and output listeners
@ -725,7 +727,7 @@ export type PropertyAliases = {
*
* e.g. [0, 'change-minified']
*/
export type PropertyAliasValue = (number | string)[];
export type PropertyAliasValue = (number|string)[];
/**
* This array contains information about input properties that
@ -745,7 +747,7 @@ export type PropertyAliasValue = (number | string)[];
*
* e.g. [null, ['role-min', 'minified-input', 'button']]
*/
export type InitialInputData = (InitialInputs | null)[];
export type InitialInputData = (InitialInputs|null)[];
/**
* Used by InitialInputData to store input properties
@ -766,7 +768,7 @@ export const unusedValueExportToPlacateAjd = 1;
/**
* Type representing a set of TNodes that can have local refs (`#foo`) placed on them.
*/
export type TNodeWithLocalRefs = TContainerNode | TElementNode | TElementContainerNode;
export type TNodeWithLocalRefs = TContainerNode|TElementNode|TElementContainerNode;
/**
* Type for a function that extracts a value for a local refs.

View File

@ -25,7 +25,9 @@ export const enum BindingType {
Style = 2,
}
export interface BindingStore { setValue(prop: string, value: any): void; }
export interface BindingStore {
setValue(prop: string, value: any): void;
}
/**
* Defines the shape which produces the Player.
@ -50,7 +52,9 @@ export interface PlayerFactoryBuildFn {
* `[style]`, `[style.prop]`, `[class]` and `[class.name]` template bindings
* all accept a `PlayerFactory` as input and this player factories.
*/
export interface PlayerFactory { '__brand__': 'Brand for PlayerFactory that nothing will match'; }
export interface PlayerFactory {
'__brand__': 'Brand for PlayerFactory that nothing will match';
}
export interface PlayerBuilder extends BindingStore {
buildPlayer(currentPlayer: Player|null, isFirstRender: boolean): Player|undefined|null;
@ -63,7 +67,13 @@ export interface PlayerBuilder extends BindingStore {
* code may compare state by checking if a number is higher or lower than
* a certain numeric value.
*/
export const enum PlayState {Pending = 0, Running = 1, Paused = 2, Finished = 100, Destroyed = 200}
export const enum PlayState {
Pending = 0,
Running = 1,
Paused = 2,
Finished = 100,
Destroyed = 200
}
/**
* The context that stores all the active players and queued player factories present on an element.

View File

@ -37,7 +37,7 @@
*
* See more examples in node_selector_matcher_spec.ts
*/
export type CssSelector = (string | SelectorFlags)[];
export type CssSelector = (string|SelectorFlags)[];
/**
* A list of CssSelectors.
@ -58,7 +58,7 @@ export type CssSelectorList = CssSelector[];
* using {@link ViewContainerRef#createComponent}. The last slot that specifies the
* wildcard selector will retrieve all projectable nodes which do not match any selector.
*/
export type ProjectionSlots = (CssSelectorList | '*')[];
export type ProjectionSlots = (CssSelectorList|'*')[];
/** Flags used to build up CssSelectors */
export const enum SelectorFlags {

View File

@ -145,7 +145,7 @@ export interface TQueries {
template(tView: TView, tNode: TNode): void;
/**
* A proxy method that iterates over all the TQueries in a given TView and calls the corresponding
* A proxy method that iterates over all the TQueries in a given TView and calls the corresponding
* `embeddedTView` on each and every TQuery.
* @param tNode
*/

View File

@ -24,9 +24,9 @@ export enum RendererStyleFlags3 {
DashCase = 1 << 1
}
export type Renderer3 = ObjectOrientedRenderer3 | ProceduralRenderer3;
export type Renderer3 = ObjectOrientedRenderer3|ProceduralRenderer3;
export type GlobalTargetName = 'document' | 'window' | 'body';
export type GlobalTargetName = 'document'|'window'|'body';
export type GlobalTargetResolver = (element: any) => {
name: GlobalTargetName, target: EventTarget
@ -49,8 +49,8 @@ export interface ObjectOrientedRenderer3 {
}
/** Returns whether the `renderer` is a `ProceduralRenderer3` */
export function isProceduralRenderer(renderer: ProceduralRenderer3 | ObjectOrientedRenderer3):
renderer is ProceduralRenderer3 {
export function isProceduralRenderer(renderer: ProceduralRenderer3|
ObjectOrientedRenderer3): renderer is ProceduralRenderer3 {
return !!((renderer as any).listen);
}
@ -104,8 +104,9 @@ export interface RendererFactory3 {
}
export const domRendererFactory3: RendererFactory3 = {
createRenderer: (hostElement: RElement | null, rendererType: RendererType2 | null):
Renderer3 => { return getDocument();}
createRenderer: (hostElement: RElement|null, rendererType: RendererType2|null): Renderer3 => {
return getDocument();
}
};
/** Subset of API needed for appending elements and text nodes. */
@ -175,9 +176,13 @@ export interface RDomTokenList {
remove(token: string): void;
}
export interface RText extends RNode { textContent: string|null; }
export interface RText extends RNode {
textContent: string|null;
}
export interface RComment extends RNode { textContent: string|null; }
export interface RComment extends RNode {
textContent: string|null;
}
// Note: This hack is necessary so we don't erroneously get a circular dependency
// failure based on types.

View File

@ -1,10 +1,10 @@
/**
* @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
*/
* @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 {KeyValueArray} from '../../util/array_utils';
import {assertNumber, assertNumberInRange} from '../../util/assert';
@ -14,7 +14,7 @@ import {assertNumber, assertNumberInRange} from '../../util/assert';
*
* See: `TStylingKeyPrimitive` and `TStylingStatic`
*/
export type TStylingKey = TStylingKeyPrimitive | TStylingStatic;
export type TStylingKey = TStylingKeyPrimitive|TStylingStatic;
/**
@ -27,7 +27,7 @@ export type TStylingKey = TStylingKeyPrimitive | TStylingStatic;
* is combined with directive which shadows its input `@Input('class')`. That way the binding
* should not participate in the styling resolution.
*/
export type TStylingKeyPrimitive = string | null | false;
export type TStylingKeyPrimitive = string|null|false;
/**
* Store the static values for the styling binding.
@ -119,7 +119,9 @@ export interface TStylingStatic extends KeyValueArray<any> {}
*
* NOTE: `0` has special significance and represents `null` as in no additional pointer.
*/
export interface TStylingRange { __brand__: 'TStylingRange'; }
export interface TStylingRange {
__brand__: 'TStylingRange';
}
/**
* Shift and masks constants for encoding two numbers into and duplicate info into a single number.
@ -177,9 +179,8 @@ export function setTStylingRangePrev(
tStylingRange: TStylingRange, previous: number): TStylingRange {
ngDevMode && assertNumber(tStylingRange, 'expected number');
ngDevMode && assertNumberInRange(previous, 0, StylingRange.UNSIGNED_MASK);
return (
((tStylingRange as any as number) & ~StylingRange.PREV_MASK) |
(previous << StylingRange.PREV_SHIFT)) as any;
return (((tStylingRange as any as number) & ~StylingRange.PREV_MASK) |
(previous << StylingRange.PREV_SHIFT)) as any;
}
export function setTStylingRangePrevDuplicate(tStylingRange: TStylingRange): TStylingRange {
@ -195,9 +196,8 @@ export function getTStylingRangeNext(tStylingRange: TStylingRange): number {
export function setTStylingRangeNext(tStylingRange: TStylingRange, next: number): TStylingRange {
ngDevMode && assertNumber(tStylingRange, 'expected number');
ngDevMode && assertNumberInRange(next, 0, StylingRange.UNSIGNED_MASK);
return (
((tStylingRange as any as number) & ~StylingRange.NEXT_MASK) | //
next << StylingRange.NEXT_SHIFT) as any;
return (((tStylingRange as any as number) & ~StylingRange.NEXT_MASK) | //
next << StylingRange.NEXT_SHIFT) as any;
}
export function getTStylingRangeNextDuplicate(tStylingRange: TStylingRange): boolean {

View File

@ -15,10 +15,10 @@ import {FLAGS, LView, LViewFlags} from './view';
/**
* True if `value` is `LView`.
* @param value wrapped value of `RNode`, `LView`, `LContainer`
*/
export function isLView(value: RNode | LView | LContainer | {} | null): value is LView {
* True if `value` is `LView`.
* @param value wrapped value of `RNode`, `LView`, `LContainer`
*/
export function isLView(value: RNode|LView|LContainer|{}|null): value is LView {
return Array.isArray(value) && typeof value[TYPE] === 'object';
}
@ -26,7 +26,7 @@ export function isLView(value: RNode | LView | LContainer | {} | null): value is
* True if `value` is `LContainer`.
* @param value wrapped value of `RNode`, `LView`, `LContainer`
*/
export function isLContainer(value: RNode | LView | LContainer | {} | null): value is LContainer {
export function isLContainer(value: RNode|LView|LContainer|{}|null): value is LContainer {
return Array.isArray(value) && value[TYPE] === true;
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {R3DirectiveMetadataFacade, getCompilerFacade} from '../../compiler/compiler_facade';
import {getCompilerFacade, R3DirectiveMetadataFacade} from '../../compiler/compiler_facade';
import {R3ComponentMetadataFacade, R3QueryMetadataFacade} from '../../compiler/compiler_facade_interface';
import {resolveForwardRef} from '../../di/forward_ref';
import {getReflect, reflectDependencies} from '../../di/jit/util';
@ -95,12 +95,14 @@ export function compileComponent(type: Type<any>, metadata: Component): void {
const meta: R3ComponentMetadataFacade = {
...directiveMetadata(type, metadata),
typeSourceSpan: compiler.createParseSourceSpan('Component', type.name, templateUrl),
template: metadata.template || '', preserveWhitespaces,
template: metadata.template || '',
preserveWhitespaces,
styles: metadata.styles || EMPTY_ARRAY,
animations: metadata.animations,
directives: [],
changeDetection: metadata.changeDetection,
pipes: new Map(), encapsulation,
pipes: new Map(),
encapsulation,
interpolation: metadata.interpolation,
viewProviders: metadata.viewProviders || null,
};
@ -135,7 +137,7 @@ export function compileComponent(type: Type<any>, metadata: Component): void {
function hasSelectorScope<T>(component: Type<T>): component is Type<T>&
{ngSelectorScope: Type<any>} {
return (component as{ngSelectorScope?: any}).ngSelectorScope !== undefined;
return (component as {ngSelectorScope?: any}).ngSelectorScope !== undefined;
}
/**
@ -145,7 +147,7 @@ function hasSelectorScope<T>(component: Type<T>): component is Type<T>&
* In the event that compilation is not immediate, `compileDirective` will return a `Promise` which
* will resolve when compilation completes and the directive becomes usable.
*/
export function compileDirective(type: Type<any>, directive: Directive | null): void {
export function compileDirective(type: Type<any>, directive: Directive|null): void {
let ngDirectiveDef: any = null;
addDirectiveFactoryDef(type, directive || {});
@ -179,7 +181,7 @@ function getDirectiveMetadata(type: Type<any>, metadata: Directive) {
return {metadata: facade, sourceMapUrl};
}
function addDirectiveFactoryDef(type: Type<any>, metadata: Directive | Component) {
function addDirectiveFactoryDef(type: Type<any>, metadata: Directive|Component) {
let ngFactoryDef: any = null;
Object.defineProperty(type, NG_FACTORY_DEF, {
@ -225,7 +227,7 @@ export function directiveMetadata(type: Type<any>, metadata: Directive): R3Direc
outputs: metadata.outputs || EMPTY_ARRAY,
queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
lifecycle: {usesOnChanges: reflect.hasLifecycleHook(type, 'ngOnChanges')},
typeSourceSpan: null !,
typeSourceSpan: null!,
usesInheritance: !extendsDirectlyFromObject(type),
exportAs: extractExportAs(metadata.exportAs),
providers: metadata.providers || null,
@ -291,7 +293,7 @@ function extractQueriesMetadata(
return queriesMeta;
}
function extractExportAs(exportAs: string | undefined): string[]|null {
function extractExportAs(exportAs: string|undefined): string[]|null {
return exportAs === undefined ? null : splitByComma(exportAs);
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {R3InjectorMetadataFacade, getCompilerFacade} from '../../compiler/compiler_facade';
import {getCompilerFacade, R3InjectorMetadataFacade} from '../../compiler/compiler_facade';
import {resolveForwardRef} from '../../di/forward_ref';
import {NG_INJ_DEF} from '../../di/interface/defs';
import {reflectDependencies} from '../../di/jit/util';
@ -70,7 +70,7 @@ export function flushModuleScopingQueueAsMuchAsPossible() {
* an array of declarations, it will recurse to check each declaration in that array
* (which may also be arrays).
*/
function isResolvedDeclaration(declaration: any[] | Type<any>): boolean {
function isResolvedDeclaration(declaration: any[]|Type<any>): boolean {
if (Array.isArray(declaration)) {
return declaration.every(isResolvedDeclaration);
}
@ -144,8 +144,9 @@ export function compileNgModuleDefs(
Object.defineProperty(moduleType, NG_INJ_DEF, {
get: () => {
if (ngInjectorDef === null) {
ngDevMode && verifySemanticsOfNgModuleDef(
moduleType as any as NgModuleType, allowDuplicateDeclarationsInRoot);
ngDevMode &&
verifySemanticsOfNgModuleDef(
moduleType as any as NgModuleType, allowDuplicateDeclarationsInRoot);
const meta: R3InjectorMetadataFacade = {
name: moduleType.name,
type: moduleType,
@ -174,10 +175,10 @@ function verifySemanticsOfNgModuleDef(
moduleType = resolveForwardRef(moduleType);
let ngModuleDef: NgModuleDef<any>;
if (importingModule) {
ngModuleDef = getNgModuleDef(moduleType) !;
ngModuleDef = getNgModuleDef(moduleType)!;
if (!ngModuleDef) {
throw new Error(
`Unexpected value '${moduleType.name}' imported by the module '${importingModule.name}'. Please add an @NgModule annotation.`);
throw new Error(`Unexpected value '${moduleType.name}' imported by the module '${
importingModule.name}'. Please add an @NgModule annotation.`);
}
} else {
ngModuleDef = getNgModuleDef(moduleType, true);
@ -222,8 +223,8 @@ function verifySemanticsOfNgModuleDef(
type = resolveForwardRef(type);
const def = getComponentDef(type) || getDirectiveDef(type) || getPipeDef(type);
if (!def) {
errors.push(
`Unexpected value '${stringifyForError(type)}' declared by the module '${stringifyForError(moduleType)}'. Please add a @Pipe/@Directive/@Component annotation.`);
errors.push(`Unexpected value '${stringifyForError(type)}' declared by the module '${
stringifyForError(moduleType)}'. Please add a @Pipe/@Directive/@Component annotation.`);
}
}
@ -244,8 +245,8 @@ function verifySemanticsOfNgModuleDef(
// Modules don't need to be declared or imported.
if (combinedDeclarations.lastIndexOf(type) === -1) {
// We are exporting something which we don't explicitly declare or import.
errors.push(
`Can't export ${kind} ${stringifyForError(type)} from ${stringifyForError(moduleType)} as it was neither declared nor imported!`);
errors.push(`Can't export ${kind} ${stringifyForError(type)} from ${
stringifyForError(moduleType)} as it was neither declared nor imported!`);
}
}
}
@ -257,9 +258,13 @@ function verifySemanticsOfNgModuleDef(
if (!suppressErrors) {
const modules = [existingModule, moduleType].map(stringifyForError).sort();
errors.push(
`Type ${stringifyForError(type)} is part of the declarations of 2 modules: ${modules[0]} and ${modules[1]}! ` +
`Please consider moving ${stringifyForError(type)} to a higher module that imports ${modules[0]} and ${modules[1]}. ` +
`You can also create a new NgModule that exports and includes ${stringifyForError(type)} then import that NgModule in ${modules[0]} and ${modules[1]}.`);
`Type ${stringifyForError(type)} is part of the declarations of 2 modules: ${
modules[0]} and ${modules[1]}! ` +
`Please consider moving ${stringifyForError(type)} to a higher module that imports ${
modules[0]} and ${modules[1]}. ` +
`You can also create a new NgModule that exports and includes ${
stringifyForError(
type)} then import that NgModule in ${modules[0]} and ${modules[1]}.`);
}
} else {
// Mark type as having owner.
@ -271,8 +276,9 @@ function verifySemanticsOfNgModuleDef(
type = resolveForwardRef(type);
const existingModule = ownerNgModule.get(type);
if (!existingModule) {
errors.push(
`Component ${stringifyForError(type)} is not part of any NgModule or the module has not been imported into your module.`);
errors.push(`Component ${
stringifyForError(
type)} is not part of any NgModule or the module has not been imported into your module.`);
}
}
@ -298,19 +304,19 @@ function verifySemanticsOfNgModuleDef(
type = resolveForwardRef(type);
if (getComponentDef(type) || getDirectiveDef(type)) {
throw new Error(
`Unexpected directive '${type.name}' imported by the module '${importingModule.name}'. Please add an @NgModule annotation.`);
throw new Error(`Unexpected directive '${type.name}' imported by the module '${
importingModule.name}'. Please add an @NgModule annotation.`);
}
if (getPipeDef(type)) {
throw new Error(
`Unexpected pipe '${type.name}' imported by the module '${importingModule.name}'. Please add an @NgModule annotation.`);
throw new Error(`Unexpected pipe '${type.name}' imported by the module '${
importingModule.name}'. Please add an @NgModule annotation.`);
}
}
}
function unwrapModuleWithProvidersImports(
typeOrWithProviders: NgModuleType<any>| {ngModule: NgModuleType<any>}): NgModuleType<any> {
function unwrapModuleWithProvidersImports(typeOrWithProviders: NgModuleType<any>|
{ngModule: NgModuleType<any>}): NgModuleType<any> {
typeOrWithProviders = resolveForwardRef(typeOrWithProviders);
return (typeOrWithProviders as any).ngModule || typeOrWithProviders;
}
@ -321,7 +327,7 @@ function getAnnotation<T>(type: any, name: string): T|null {
collect(type.decorators);
return annotation;
function collect(annotations: any[] | null) {
function collect(annotations: any[]|null) {
if (annotations) {
annotations.forEach(readAnnotation);
}
@ -391,7 +397,7 @@ function setScopeOnDeclaredComponents(moduleType: Type<any>, ngModule: NgModule)
if (declaration.hasOwnProperty(NG_COMP_DEF)) {
// A `ɵcmp` field exists - go ahead and patch the component directly.
const component = declaration as Type<any>& {ɵcmp: ComponentDef<any>};
const componentDef = getComponentDef(component) !;
const componentDef = getComponentDef(component)!;
patchComponentDefWithScope(componentDef, transitiveScopes);
} else if (
!declaration.hasOwnProperty(NG_DIR_DEF) && !declaration.hasOwnProperty(NG_PIPE_DEF)) {
@ -410,11 +416,11 @@ export function patchComponentDefWithScope<C>(
componentDef.directiveDefs = () =>
Array.from(transitiveScopes.compilation.directives)
.map(
dir =>
dir.hasOwnProperty(NG_COMP_DEF) ? getComponentDef(dir) ! : getDirectiveDef(dir) !)
dir => dir.hasOwnProperty(NG_COMP_DEF) ? getComponentDef(dir)! : getDirectiveDef(dir)!
)
.filter(def => !!def);
componentDef.pipeDefs = () =>
Array.from(transitiveScopes.compilation.pipes).map(pipe => getPipeDef(pipe) !);
Array.from(transitiveScopes.compilation.pipes).map(pipe => getPipeDef(pipe)!);
componentDef.schemas = transitiveScopes.schemas;
// Since we avoid Components/Directives/Pipes recompiling in case there are no overrides, we
@ -437,7 +443,7 @@ export function transitiveScopesFor<T>(moduleType: Type<T>): NgModuleTransitiveS
if (!isNgModule(moduleType)) {
throw new Error(`${moduleType.name} does not have a module def (ɵmod property)`);
}
const def = getNgModuleDef(moduleType) !;
const def = getNgModuleDef(moduleType)!;
if (def.transitiveCompileScopes !== null) {
return def.transitiveCompileScopes;
@ -473,7 +479,9 @@ export function transitiveScopesFor<T>(moduleType: Type<T>): NgModuleTransitiveS
});
maybeUnwrapFn(def.declarations).forEach(declared => {
const declaredWithDefs = declared as Type<any>& { ɵpipe?: any; };
const declaredWithDefs = declared as Type<any>& {
ɵpipe?: any;
};
if (getPipeDef(declaredWithDefs)) {
scopes.compilation.pipes.add(declared);
@ -519,7 +527,7 @@ export function transitiveScopesFor<T>(moduleType: Type<T>): NgModuleTransitiveS
return scopes;
}
function expandModuleWithProviders(value: Type<any>| ModuleWithProviders<{}>): Type<any> {
function expandModuleWithProviders(value: Type<any>|ModuleWithProviders<{}>): Type<any> {
if (isModuleWithProviders(value)) {
return value.ngModule;
}
@ -527,7 +535,7 @@ function expandModuleWithProviders(value: Type<any>| ModuleWithProviders<{}>): T
}
function isModuleWithProviders(value: any): value is ModuleWithProviders<{}> {
return (value as{ngModule?: any}).ngModule !== undefined;
return (value as {ngModule?: any}).ngModule !== undefined;
}
function isNgModule<T>(value: Type<T>): value is Type<T>&{ɵmod: NgModuleDef<T>} {

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {R3PipeMetadataFacade, getCompilerFacade} from '../../compiler/compiler_facade';
import {getCompilerFacade, R3PipeMetadataFacade} from '../../compiler/compiler_facade';
import {reflectDependencies} from '../../di/jit/util';
import {Type} from '../../interface/type';
import {Pipe} from '../../metadata/directives';

View File

@ -25,43 +25,46 @@ interface TypeWithMetadata extends Type<any> {
* tree-shaken away during production builds.
*/
export function setClassMetadata(
type: Type<any>, decorators: any[] | null, ctorParameters: (() => any[]) | null,
propDecorators: {[field: string]: any} | null): void {
type: Type<any>, decorators: any[]|null, ctorParameters: (() => any[])|null,
propDecorators: {[field: string]: any}|null): void {
return noSideEffects(() => {
const clazz = type as TypeWithMetadata;
const clazz = type as TypeWithMetadata;
// We determine whether a class has its own metadata by taking the metadata from the parent
// constructor and checking whether it's the same as the subclass metadata below. We can't use
// `hasOwnProperty` here because it doesn't work correctly in IE10 for static fields that are
// defined by TS. See https://github.com/angular/angular/pull/28439#issuecomment-459349218.
const parentPrototype = clazz.prototype ? Object.getPrototypeOf(clazz.prototype) : null;
const parentConstructor: TypeWithMetadata|null = parentPrototype && parentPrototype.constructor;
// We determine whether a class has its own metadata by taking the metadata from the
// parent constructor and checking whether it's the same as the subclass metadata below.
// We can't use `hasOwnProperty` here because it doesn't work correctly in IE10 for
// static fields that are defined by TS. See
// https://github.com/angular/angular/pull/28439#issuecomment-459349218.
const parentPrototype = clazz.prototype ? Object.getPrototypeOf(clazz.prototype) : null;
const parentConstructor: TypeWithMetadata|null =
parentPrototype && parentPrototype.constructor;
if (decorators !== null) {
if (clazz.decorators !== undefined &&
(!parentConstructor || parentConstructor.decorators !== clazz.decorators)) {
clazz.decorators.push(...decorators);
} else {
clazz.decorators = decorators;
}
}
if (ctorParameters !== null) {
// Rather than merging, clobber the existing parameters. If other projects exist which use
// tsickle-style annotations and reflect over them in the same way, this could cause issues,
// but that is vanishingly unlikely.
clazz.ctorParameters = ctorParameters;
}
if (propDecorators !== null) {
// The property decorator objects are merged as it is possible different fields have different
// decorator types. Decorators on individual fields are not merged, as it's also incredibly
// unlikely that a field will be decorated both with an Angular decorator and a non-Angular
// decorator that's also been downleveled.
if (clazz.propDecorators !== undefined &&
(!parentConstructor || parentConstructor.propDecorators !== clazz.propDecorators)) {
clazz.propDecorators = {...clazz.propDecorators, ...propDecorators};
} else {
clazz.propDecorators = propDecorators;
}
}
}) as never;
if (decorators !== null) {
if (clazz.decorators !== undefined &&
(!parentConstructor || parentConstructor.decorators !== clazz.decorators)) {
clazz.decorators.push(...decorators);
} else {
clazz.decorators = decorators;
}
}
if (ctorParameters !== null) {
// Rather than merging, clobber the existing parameters. If other projects exist which
// use tsickle-style annotations and reflect over them in the same way, this could
// cause issues, but that is vanishingly unlikely.
clazz.ctorParameters = ctorParameters;
}
if (propDecorators !== null) {
// The property decorator objects are merged as it is possible different fields have
// different decorator types. Decorators on individual fields are not merged, as it's
// also incredibly unlikely that a field will be decorated both with an Angular
// decorator and a non-Angular decorator that's also been downleveled.
if (clazz.propDecorators !== undefined &&
(!parentConstructor ||
parentConstructor.propDecorators !== clazz.propDecorators)) {
clazz.propDecorators = {...clazz.propDecorators, ...propDecorators};
} else {
clazz.propDecorators = propDecorators;
}
}
}) as never;
}

View File

@ -9,7 +9,7 @@
import {Injector} from '../di/injector';
import {INJECTOR} from '../di/injector_compatibility';
import {InjectFlags} from '../di/interface/injector';
import {R3Injector, createInjectorWithoutInjectorInstances} from '../di/r3_injector';
import {createInjectorWithoutInjectorInstances, R3Injector} from '../di/r3_injector';
import {Type} from '../interface/type';
import {ComponentFactoryResolver as viewEngine_ComponentFactoryResolver} from '../linker/component_factory_resolver';
import {InternalNgModuleRef, NgModuleFactory as viewEngine_NgModuleFactory, NgModuleRef as viewEngine_NgModuleRef} from '../linker/ng_module_factory';
@ -23,7 +23,9 @@ import {getNgLocaleIdDef, getNgModuleDef} from './definition';
import {setLocaleId} from './i18n';
import {maybeUnwrapFn} from './util/misc_utils';
export interface NgModuleType<T = any> extends Type<T> { ɵmod: NgModuleDef<T>; }
export interface NgModuleType<T = any> extends Type<T> {
ɵmod: NgModuleDef<T>;
}
export class NgModuleRef<T> extends viewEngine_NgModuleRef<T> implements InternalNgModuleRef<T> {
// tslint:disable-next-line:require-internal-with-underscore
@ -45,20 +47,23 @@ export class NgModuleRef<T> extends viewEngine_NgModuleRef<T> implements Interna
constructor(ngModuleType: Type<T>, public _parent: Injector|null) {
super();
const ngModuleDef = getNgModuleDef(ngModuleType);
ngDevMode && assertDefined(
ngModuleDef,
`NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
ngDevMode &&
assertDefined(
ngModuleDef,
`NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
const ngLocaleIdDef = getNgLocaleIdDef(ngModuleType);
ngLocaleIdDef && setLocaleId(ngLocaleIdDef);
this._bootstrapComponents = maybeUnwrapFn(ngModuleDef !.bootstrap);
this._bootstrapComponents = maybeUnwrapFn(ngModuleDef!.bootstrap);
this._r3Injector = createInjectorWithoutInjectorInstances(
ngModuleType, _parent,
[
{provide: viewEngine_NgModuleRef, useValue: this},
{provide: viewEngine_ComponentFactoryResolver, useValue: this.componentFactoryResolver}
],
stringify(ngModuleType)) as R3Injector;
ngModuleType, _parent,
[
{provide: viewEngine_NgModuleRef, useValue: this}, {
provide: viewEngine_ComponentFactoryResolver,
useValue: this.componentFactoryResolver
}
],
stringify(ngModuleType)) as R3Injector;
// We need to resolve the injector types separately from the injector creation, because
// the module might be trying to use this ref in its contructor for DI which will cause a
@ -79,12 +84,12 @@ export class NgModuleRef<T> extends viewEngine_NgModuleRef<T> implements Interna
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
const injector = this._r3Injector;
!injector.destroyed && injector.destroy();
this.destroyCbs !.forEach(fn => fn());
this.destroyCbs!.forEach(fn => fn());
this.destroyCbs = null;
}
onDestroy(callback: () => void): void {
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
this.destroyCbs !.push(callback);
this.destroyCbs!.push(callback);
}
}

View File

@ -46,7 +46,7 @@ function isCssClassMatching(
}
} else if (item === AttributeMarker.Classes) {
// We found the classes section. Start searching for the class.
while (i < attrs.length && typeof(item = attrs[i++]) == 'string') {
while (i < attrs.length && typeof (item = attrs[i++]) == 'string') {
// while we have strings
if (item.toLowerCase() === cssClassToMatch) return true;
}
@ -151,9 +151,10 @@ export function isNodeMatchingSelector(
if (attrIndexInNode > nameOnlyMarkerIdx) {
nodeAttrValue = '';
} else {
ngDevMode && assertNotEqual(
nodeAttrs[attrIndexInNode], AttributeMarker.NamespaceURI,
'We do not match directives on namespaced attributes');
ngDevMode &&
assertNotEqual(
nodeAttrs[attrIndexInNode], AttributeMarker.NamespaceURI,
'We do not match directives on namespaced attributes');
// we lowercase the attribute value to be able to match
// selectors without case-sensitivity
// (selectors are already in lowercase when generated)
@ -208,7 +209,7 @@ function isPositive(mode: SelectorFlags): boolean {
* matching against directives.
*/
function findAttrIndexInNode(
name: string, attrs: TAttributes | null, isInlineTemplate: boolean,
name: string, attrs: TAttributes|null, isInlineTemplate: boolean,
isProjectionMode: boolean): number {
if (attrs === null) return -1;

View File

@ -43,7 +43,7 @@ export function getParentInjectorTNode(
let parentTNode = startView[T_HOST] as TElementNode;
// view offset is superior to 1
while (viewOffset > 1) {
parentView = parentView[DECLARATION_VIEW] !;
parentView = parentView[DECLARATION_VIEW]!;
parentTNode = parentView[T_HOST] as TElementNode;
viewOffset--;
}

View File

@ -61,7 +61,7 @@ export function ɵɵpipe(index: number, pipeName: string): any {
* @param registry Full list of available pipes
* @returns Matching PipeDef
*/
function getPipeDef(name: string, registry: PipeDefList | null): PipeDef<any> {
function getPipeDef(name: string, registry: PipeDefList|null): PipeDef<any> {
if (registry) {
for (let i = registry.length - 1; i >= 0; i--) {
const pipeDef = registry[i];
@ -89,7 +89,8 @@ export function ɵɵpipeBind1(index: number, slotOffset: number, v1: any): any {
const lView = getLView();
const pipeInstance = load<PipeTransform>(lView, index);
return unwrapValue(
lView, isPure(lView, index) ?
lView,
isPure(lView, index) ?
pureFunction1Internal(
lView, getBindingRoot(), slotOffset, pipeInstance.transform, v1, pipeInstance) :
pipeInstance.transform(v1));
@ -112,7 +113,8 @@ export function ɵɵpipeBind2(index: number, slotOffset: number, v1: any, v2: an
const lView = getLView();
const pipeInstance = load<PipeTransform>(lView, index);
return unwrapValue(
lView, isPure(lView, index) ?
lView,
isPure(lView, index) ?
pureFunction2Internal(
lView, getBindingRoot(), slotOffset, pipeInstance.transform, v1, v2, pipeInstance) :
pipeInstance.transform(v1, v2));
@ -136,10 +138,11 @@ export function ɵɵpipeBind3(index: number, slotOffset: number, v1: any, v2: an
const lView = getLView();
const pipeInstance = load<PipeTransform>(lView, index);
return unwrapValue(
lView, isPure(lView, index) ? pureFunction3Internal(
lView, getBindingRoot(), slotOffset, pipeInstance.transform,
v1, v2, v3, pipeInstance) :
pipeInstance.transform(v1, v2, v3));
lView,
isPure(lView, index) ? pureFunction3Internal(
lView, getBindingRoot(), slotOffset, pipeInstance.transform, v1,
v2, v3, pipeInstance) :
pipeInstance.transform(v1, v2, v3));
}
/**
@ -162,10 +165,11 @@ export function ɵɵpipeBind4(
const lView = getLView();
const pipeInstance = load<PipeTransform>(lView, index);
return unwrapValue(
lView, isPure(lView, index) ? pureFunction4Internal(
lView, getBindingRoot(), slotOffset, pipeInstance.transform,
v1, v2, v3, v4, pipeInstance) :
pipeInstance.transform(v1, v2, v3, v4));
lView,
isPure(lView, index) ? pureFunction4Internal(
lView, getBindingRoot(), slotOffset, pipeInstance.transform, v1,
v2, v3, v4, pipeInstance) :
pipeInstance.transform(v1, v2, v3, v4));
}
/**
@ -184,7 +188,8 @@ export function ɵɵpipeBindV(index: number, slotOffset: number, values: [any, .
const lView = getLView();
const pipeInstance = load<PipeTransform>(lView, index);
return unwrapValue(
lView, isPure(lView, index) ?
lView,
isPure(lView, index) ?
pureFunctionVInternal(
lView, getBindingRoot(), slotOffset, pipeInstance.transform, values, pipeInstance) :
pipeInstance.transform.apply(pipeInstance, values));

View File

@ -154,8 +154,9 @@ export function ɵɵpureFunction5(
const different = bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4);
return bindingUpdated(lView, bindingIndex + 4, exp5) || different ?
updateBinding(
lView, bindingIndex + 5, thisArg ? pureFn.call(thisArg, exp1, exp2, exp3, exp4, exp5) :
pureFn(exp1, exp2, exp3, exp4, exp5)) :
lView, bindingIndex + 5,
thisArg ? pureFn.call(thisArg, exp1, exp2, exp3, exp4, exp5) :
pureFn(exp1, exp2, exp3, exp4, exp5)) :
getBinding(lView, bindingIndex + 5);
}
@ -184,9 +185,9 @@ export function ɵɵpureFunction6(
const different = bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4);
return bindingUpdated2(lView, bindingIndex + 4, exp5, exp6) || different ?
updateBinding(
lView, bindingIndex + 6, thisArg ?
pureFn.call(thisArg, exp1, exp2, exp3, exp4, exp5, exp6) :
pureFn(exp1, exp2, exp3, exp4, exp5, exp6)) :
lView, bindingIndex + 6,
thisArg ? pureFn.call(thisArg, exp1, exp2, exp3, exp4, exp5, exp6) :
pureFn(exp1, exp2, exp3, exp4, exp5, exp6)) :
getBinding(lView, bindingIndex + 6);
}
@ -217,9 +218,9 @@ export function ɵɵpureFunction7(
let different = bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4);
return bindingUpdated3(lView, bindingIndex + 4, exp5, exp6, exp7) || different ?
updateBinding(
lView, bindingIndex + 7, thisArg ?
pureFn.call(thisArg, exp1, exp2, exp3, exp4, exp5, exp6, exp7) :
pureFn(exp1, exp2, exp3, exp4, exp5, exp6, exp7)) :
lView, bindingIndex + 7,
thisArg ? pureFn.call(thisArg, exp1, exp2, exp3, exp4, exp5, exp6, exp7) :
pureFn(exp1, exp2, exp3, exp4, exp5, exp6, exp7)) :
getBinding(lView, bindingIndex + 7);
}
@ -252,9 +253,9 @@ export function ɵɵpureFunction8(
const different = bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4);
return bindingUpdated4(lView, bindingIndex + 4, exp5, exp6, exp7, exp8) || different ?
updateBinding(
lView, bindingIndex + 8, thisArg ?
pureFn.call(thisArg, exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8) :
pureFn(exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8)) :
lView, bindingIndex + 8,
thisArg ? pureFn.call(thisArg, exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8) :
pureFn(exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8)) :
getBinding(lView, bindingIndex + 8);
}

View File

@ -36,8 +36,12 @@ const unusedValueToPlacateAjd = unused1 + unused2 + unused3 + unused4;
class LQuery_<T> implements LQuery<T> {
matches: (T|null)[]|null = null;
constructor(public queryList: QueryList<T>) {}
clone(): LQuery<T> { return new LQuery_(this.queryList); }
setDirty(): void { this.queryList.setDirty(); }
clone(): LQuery<T> {
return new LQuery_(this.queryList);
}
setDirty(): void {
this.queryList.setDirty();
}
}
class LQueries_ implements LQueries {
@ -66,9 +70,13 @@ class LQueries_ implements LQueries {
return null;
}
insertView(tView: TView): void { this.dirtyQueriesWithMatches(tView); }
insertView(tView: TView): void {
this.dirtyQueriesWithMatches(tView);
}
detachView(tView: TView): void { this.dirtyQueriesWithMatches(tView); }
detachView(tView: TView): void {
this.dirtyQueriesWithMatches(tView);
}
private dirtyQueriesWithMatches(tView: TView) {
for (let i = 0; i < this.queries.length; i++) {
@ -89,8 +97,9 @@ class TQueries_ implements TQueries {
constructor(private queries: TQuery[] = []) {}
elementStart(tView: TView, tNode: TNode): void {
ngDevMode && assertFirstCreatePass(
tView, 'Queries should collect results on the first template pass only');
ngDevMode &&
assertFirstCreatePass(
tView, 'Queries should collect results on the first template pass only');
for (let i = 0; i < this.queries.length; i++) {
this.queries[i].elementStart(tView, tNode);
}
@ -121,8 +130,9 @@ class TQueries_ implements TQueries {
}
template(tView: TView, tNode: TNode): void {
ngDevMode && assertFirstCreatePass(
tView, 'Queries should collect results on the first template pass only');
ngDevMode &&
assertFirstCreatePass(
tView, 'Queries should collect results on the first template pass only');
for (let i = 0; i < this.queries.length; i++) {
this.queries[i].template(tView, tNode);
}
@ -133,9 +143,13 @@ class TQueries_ implements TQueries {
return this.queries[index];
}
get length(): number { return this.queries.length; }
get length(): number {
return this.queries.length;
}
track(tquery: TQuery): void { this.queries.push(tquery); }
track(tquery: TQuery): void {
this.queries.push(tquery);
}
}
class TQuery_ implements TQuery {
@ -173,7 +187,9 @@ class TQuery_ implements TQuery {
}
}
template(tView: TView, tNode: TNode): void { this.elementStart(tView, tNode); }
template(tView: TView, tNode: TNode): void {
this.elementStart(tView, tNode);
}
embeddedTView(tNode: TNode, childQueryIndex: number): TQuery|null {
if (this.isApplyingToNode(tNode)) {
@ -307,15 +323,17 @@ function createSpecialToken(lView: LView, tNode: TNode, read: any): any {
} else if (read === ViewEngine_TemplateRef) {
return createTemplateRef(ViewEngine_TemplateRef, ViewEngine_ElementRef, tNode, lView);
} else if (read === ViewContainerRef) {
ngDevMode && assertNodeOfPossibleTypes(
tNode, TNodeType.Element, TNodeType.Container, TNodeType.ElementContainer);
ngDevMode &&
assertNodeOfPossibleTypes(
tNode, TNodeType.Element, TNodeType.Container, TNodeType.ElementContainer);
return createContainerRef(
ViewContainerRef, ViewEngine_ElementRef,
tNode as TElementNode | TContainerNode | TElementContainerNode, lView);
} else {
ngDevMode &&
throwError(
`Special token to read should be one of ElementRef, TemplateRef or ViewContainerRef but got ${stringify(read)}.`);
`Special token to read should be one of ElementRef, TemplateRef or ViewContainerRef but got ${
stringify(read)}.`);
}
}
@ -325,11 +343,11 @@ function createSpecialToken(lView: LView, tNode: TNode, read: any): any {
* doesn't change).
*/
function materializeViewResults<T>(
tView: TView, lView: LView, tQuery: TQuery, queryIndex: number): (T | null)[] {
const lQuery = lView[QUERIES] !.queries ![queryIndex];
tView: TView, lView: LView, tQuery: TQuery, queryIndex: number): (T|null)[] {
const lQuery = lView[QUERIES]!.queries![queryIndex];
if (lQuery.matches === null) {
const tViewData = tView.data;
const tQueryMatches = tQuery.matches !;
const tQueryMatches = tQuery.matches!;
const result: T|null[] = [];
for (let i = 0; i < tQueryMatches.length; i += 2) {
const matchedNodeIdx = tQueryMatches[i];
@ -355,7 +373,7 @@ function materializeViewResults<T>(
* starting with a provided LView.
*/
function collectQueryResults<T>(tView: TView, lView: LView, queryIndex: number, result: T[]): T[] {
const tQuery = tView.queries !.getByIndex(queryIndex);
const tQuery = tView.queries!.getByIndex(queryIndex);
const tQueryMatches = tQuery.matches;
if (tQueryMatches !== null) {
const lViewResults = materializeViewResults<T>(tView, lView, tQuery, queryIndex);
@ -381,7 +399,7 @@ function collectQueryResults<T>(tView: TView, lView: LView, queryIndex: number,
// collect matches for views created from this declaration container and inserted into
// different containers
if (declarationLContainer[MOVED_VIEWS] !== null) {
const embeddedLViews = declarationLContainer[MOVED_VIEWS] !;
const embeddedLViews = declarationLContainer[MOVED_VIEWS]!;
for (let i = 0; i < embeddedLViews.length; i++) {
const embeddedLView = embeddedLViews[i];
collectQueryResults(embeddedLView[TVIEW], embeddedLView, childQueryIndex, result);
@ -436,7 +454,7 @@ export function ɵɵqueryRefresh(queryList: QueryList<any>): boolean {
* @codeGenApi
*/
export function ɵɵstaticViewQuery<T>(
predicate: Type<any>| string[], descend: boolean, read?: any): void {
predicate: Type<any>|string[], descend: boolean, read?: any): void {
viewQueryInternal(getTView(), getLView(), predicate, descend, read, true);
}
@ -449,12 +467,12 @@ export function ɵɵstaticViewQuery<T>(
*
* @codeGenApi
*/
export function ɵɵviewQuery<T>(predicate: Type<any>| string[], descend: boolean, read?: any): void {
export function ɵɵviewQuery<T>(predicate: Type<any>|string[], descend: boolean, read?: any): void {
viewQueryInternal(getTView(), getLView(), predicate, descend, read, false);
}
function viewQueryInternal<T>(
tView: TView, lView: LView, predicate: Type<any>| string[], descend: boolean, read: any,
tView: TView, lView: LView, predicate: Type<any>|string[], descend: boolean, read: any,
isStatic: boolean): void {
if (tView.firstCreatePass) {
createTQuery(tView, new TQueryMetadata_(predicate, descend, isStatic, read), -1);
@ -478,7 +496,7 @@ function viewQueryInternal<T>(
* @codeGenApi
*/
export function ɵɵcontentQuery<T>(
directiveIndex: number, predicate: Type<any>| string[], descend: boolean, read?: any): void {
directiveIndex: number, predicate: Type<any>|string[], descend: boolean, read?: any): void {
contentQueryInternal(
getTView(), getLView(), predicate, descend, read, false, getPreviousOrParentTNode(),
directiveIndex);
@ -497,14 +515,14 @@ export function ɵɵcontentQuery<T>(
* @codeGenApi
*/
export function ɵɵstaticContentQuery<T>(
directiveIndex: number, predicate: Type<any>| string[], descend: boolean, read?: any): void {
directiveIndex: number, predicate: Type<any>|string[], descend: boolean, read?: any): void {
contentQueryInternal(
getTView(), getLView(), predicate, descend, read, true, getPreviousOrParentTNode(),
directiveIndex);
}
function contentQueryInternal<T>(
tView: TView, lView: LView, predicate: Type<any>| string[], descend: boolean, read: any,
tView: TView, lView: LView, predicate: Type<any>|string[], descend: boolean, read: any,
isStatic: boolean, tNode: TNode, directiveIndex: number): void {
if (tView.firstCreatePass) {
createTQuery(tView, new TQueryMetadata_(predicate, descend, isStatic, read), tNode.index);
@ -529,8 +547,8 @@ export function ɵɵloadQuery<T>(): QueryList<T> {
function loadQueryInternal<T>(lView: LView, queryIndex: number): QueryList<T> {
ngDevMode &&
assertDefined(lView[QUERIES], 'LQueries should be defined when trying to load a query');
ngDevMode && assertDataInRange(lView[QUERIES] !.queries, queryIndex);
return lView[QUERIES] !.queries[queryIndex].queryList;
ngDevMode && assertDataInRange(lView[QUERIES]!.queries, queryIndex);
return lView[QUERIES]!.queries[queryIndex].queryList;
}
function createLQuery<T>(tView: TView, lView: LView) {
@ -538,7 +556,7 @@ function createLQuery<T>(tView: TView, lView: LView) {
storeCleanupWithContext(tView, lView, queryList, queryList.destroy);
if (lView[QUERIES] === null) lView[QUERIES] = new LQueries_();
lView[QUERIES] !.queries.push(new LQuery_(queryList));
lView[QUERIES]!.queries.push(new LQuery_(queryList));
}
function createTQuery(tView: TView, metadata: TQueryMetadata, nodeIndex: number): void {
@ -551,11 +569,11 @@ function saveContentQueryAndDirectiveIndex(tView: TView, directiveIndex: number)
const lastSavedDirectiveIndex =
tView.contentQueries.length ? tViewContentQueries[tViewContentQueries.length - 1] : -1;
if (directiveIndex !== lastSavedDirectiveIndex) {
tViewContentQueries.push(tView.queries !.length - 1, directiveIndex);
tViewContentQueries.push(tView.queries!.length - 1, directiveIndex);
}
}
function getTQuery(tView: TView, index: number): TQuery {
ngDevMode && assertDefined(tView.queries, 'TQueries must be defined to retrieve a TQuery');
return tView.queries !.getByIndex(index);
return tView.queries!.getByIndex(index);
}

View File

@ -373,7 +373,7 @@ export function enterDI(newView: LView, tNode: TNode) {
ngDevMode && assertLViewOrUndefined(newView);
const newLFrame = allocLFrame();
instructionState.lFrame = newLFrame;
newLFrame.previousOrParentTNode = tNode !;
newLFrame.previousOrParentTNode = tNode!;
newLFrame.lView = newView;
}
@ -389,7 +389,7 @@ export function enterDI(newView: LView, tNode: TNode) {
* @param tNode Element to which the View is a child of
* @returns the previously active lView;
*/
export function enterView(newView: LView, tNode: TNode | null): void {
export function enterView(newView: LView, tNode: TNode|null): void {
ngDevMode && assertLViewOrUndefined(newView);
const newLFrame = allocLFrame();
if (ngDevMode) {
@ -406,10 +406,10 @@ export function enterView(newView: LView, tNode: TNode | null): void {
}
const tView = newView[TVIEW];
instructionState.lFrame = newLFrame;
newLFrame.previousOrParentTNode = tNode !;
newLFrame.previousOrParentTNode = tNode!;
newLFrame.lView = newView;
newLFrame.tView = tView;
newLFrame.contextLView = newView !;
newLFrame.contextLView = newView!;
newLFrame.bindingIndex = tView.bindingStartIndex;
}
@ -423,23 +423,23 @@ function allocLFrame() {
return newLFrame;
}
function createLFrame(parent: LFrame | null): LFrame {
function createLFrame(parent: LFrame|null): LFrame {
const lFrame: LFrame = {
previousOrParentTNode: null !, //
isParent: true, //
lView: null !, //
tView: null !, //
selectedIndex: 0, //
contextLView: null !, //
elementDepthCount: 0, //
currentNamespace: null, //
currentSanitizer: null, //
currentDirectiveIndex: -1, //
bindingRootIndex: -1, //
bindingIndex: -1, //
currentQueryIndex: 0, //
parent: parent !, //
child: null, //
previousOrParentTNode: null!, //
isParent: true, //
lView: null!, //
tView: null!, //
selectedIndex: 0, //
contextLView: null!, //
elementDepthCount: 0, //
currentNamespace: null, //
currentSanitizer: null, //
currentDirectiveIndex: -1, //
bindingRootIndex: -1, //
bindingIndex: -1, //
currentQueryIndex: 0, //
parent: parent!, //
child: null, //
};
parent !== null && (parent.child = lFrame); // link the new LFrame for reuse.
return lFrame;
@ -457,8 +457,8 @@ function createLFrame(parent: LFrame | null): LFrame {
function leaveViewLight(): LFrame {
const oldLFrame = instructionState.lFrame;
instructionState.lFrame = oldLFrame.parent;
oldLFrame.previousOrParentTNode = null !;
oldLFrame.lView = null !;
oldLFrame.previousOrParentTNode = null!;
oldLFrame.lView = null!;
return oldLFrame;
}
@ -481,9 +481,9 @@ export const leaveDI: () => void = leaveViewLight;
export function leaveView() {
const oldLFrame = leaveViewLight();
oldLFrame.isParent = true;
oldLFrame.tView = null !;
oldLFrame.tView = null!;
oldLFrame.selectedIndex = 0;
oldLFrame.contextLView = null !;
oldLFrame.contextLView = null!;
oldLFrame.elementDepthCount = 0;
oldLFrame.currentDirectiveIndex = -1;
oldLFrame.currentNamespace = null;
@ -495,16 +495,17 @@ export function leaveView() {
export function nextContextImpl<T = any>(level: number): T {
const contextLView = instructionState.lFrame.contextLView =
walkUpViews(level, instructionState.lFrame.contextLView !);
walkUpViews(level, instructionState.lFrame.contextLView!);
return contextLView[CONTEXT] as T;
}
function walkUpViews(nestingLevel: number, currentView: LView): LView {
while (nestingLevel > 0) {
ngDevMode && assertDefined(
currentView[DECLARATION_VIEW],
'Declaration view should be defined if nesting level is greater than 0.');
currentView = currentView[DECLARATION_VIEW] !;
ngDevMode &&
assertDefined(
currentView[DECLARATION_VIEW],
'Declaration view should be defined if nesting level is greater than 0.');
currentView = currentView[DECLARATION_VIEW]!;
nestingLevel--;
}
return currentView;
@ -581,7 +582,7 @@ export function getNamespace(): string|null {
return instructionState.lFrame.currentNamespace;
}
export function setCurrentStyleSanitizer(sanitizer: StyleSanitizeFn | null) {
export function setCurrentStyleSanitizer(sanitizer: StyleSanitizeFn|null) {
instructionState.lFrame.currentSanitizer = sanitizer;
}

View File

@ -1,10 +1,10 @@
/**
* @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
*/
* @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 {assertNotEqual} from '../../util/assert';
import {CharCode} from '../../util/char_code';

View File

@ -1,10 +1,10 @@
/**
* @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
*/
* @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 {concatStringsWithSpace} from '../../util/stringify';
import {assertFirstCreatePass} from '../assert';

View File

@ -1,16 +1,16 @@
/**
* @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
*/
* @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 {KeyValueArray, keyValueArrayIndexOf} from '../../util/array_utils';
import {assertDataInRange, assertEqual, assertNotEqual} from '../../util/assert';
import {assertFirstUpdatePass} from '../assert';
import {TNode} from '../interfaces/node';
import {TStylingKey, TStylingKeyPrimitive, TStylingRange, getTStylingRangeNext, getTStylingRangePrev, setTStylingRangeNext, setTStylingRangeNextDuplicate, setTStylingRangePrev, setTStylingRangePrevDuplicate, toTStylingRange} from '../interfaces/styling';
import {getTStylingRangeNext, getTStylingRangePrev, setTStylingRangeNext, setTStylingRangeNextDuplicate, setTStylingRangePrev, setTStylingRangePrevDuplicate, toTStylingRange, TStylingKey, TStylingKeyPrimitive, TStylingRange} from '../interfaces/styling';
import {TData} from '../interfaces/view';
import {getTView} from '../state';
@ -249,9 +249,10 @@ export function insertTStylingBinding(
// We are inserting in template section.
// We need to set this binding's "previous" to the current template tail
tData[index + 1] = toTStylingRange(tmplTail, 0);
ngDevMode && assertEqual(
tmplHead !== 0 && tmplTail === 0, false,
'Adding template bindings after hostBindings is not allowed.');
ngDevMode &&
assertEqual(
tmplHead !== 0 && tmplTail === 0, false,
'Adding template bindings after hostBindings is not allowed.');
if (tmplHead === 0) {
tmplHead = index;
} else {
@ -409,13 +410,14 @@ function isStylingMatch(tStylingKeyCursor: TStylingKey, tStylingKey: TStylingKey
ngDevMode &&
assertNotEqual(
Array.isArray(tStylingKey), true, 'Expected that \'tStylingKey\' has been unwrapped');
if (tStylingKeyCursor === null || // If the cursor is `null` it means that we have map at that
if (
tStylingKeyCursor === null || // If the cursor is `null` it means that we have map at that
// location so we must assume that we have a match.
tStylingKey == null || // If `tStylingKey` is `null` then it is a map therefor assume that it
// contains a match.
(Array.isArray(tStylingKeyCursor) ? tStylingKeyCursor[1] : tStylingKeyCursor) ===
tStylingKey // If the keys match explicitly than we are a match.
) {
) {
return true;
} else if (Array.isArray(tStylingKeyCursor) && typeof tStylingKey === 'string') {
// if we did not find a match, but `tStylingKeyCursor` is `KeyValueArray` that means cursor has

View File

@ -244,7 +244,7 @@ export function consumeSeparator(
* @param startIndex Starting index of character where the scan should start.
* @param endIndex Ending index of character where the scan should end.
* @returns Index after last style value character.
*/
*/
export function consumeStyleValue(text: string, startIndex: number, endIndex: number): number {
let ch1 = -1; // 1st previous character
let ch2 = -1; // 2nd previous character

View File

@ -8,7 +8,7 @@
import {CharCode} from '../../util/char_code';
import {AttributeMarker, TAttributes} from '../interfaces/node';
import {CssSelector} from '../interfaces/projection';
import {ProceduralRenderer3, RElement, Renderer3, isProceduralRenderer} from '../interfaces/renderer';
import {isProceduralRenderer, ProceduralRenderer3, RElement, Renderer3} from '../interfaces/renderer';
@ -96,7 +96,7 @@ export function setUpAttributes(renderer: Renderer3, native: RElement, attrs: TA
* @param marker The attribute marker to test.
* @returns true if the marker is a "name-only" marker (e.g. `Bindings`, `Template` or `I18n`).
*/
export function isNameOnlyAttributeMarker(marker: string | AttributeMarker | CssSelector) {
export function isNameOnlyAttributeMarker(marker: string|AttributeMarker|CssSelector) {
return marker === AttributeMarker.Bindings || marker === AttributeMarker.Template ||
marker === AttributeMarker.I18n;
}
@ -116,7 +116,7 @@ export function isAnimationProp(name: string): boolean {
* @param dst Location of where the merged `TAttributes` should end up.
* @param src `TAttributes` which should be appended to `dst`
*/
export function mergeHostAttrs(dst: TAttributes | null, src: TAttributes | null): TAttributes|null {
export function mergeHostAttrs(dst: TAttributes|null, src: TAttributes|null): TAttributes|null {
if (src === null || src.length === 0) {
// do nothing
} else if (dst === null || dst.length === 0) {
@ -156,8 +156,8 @@ export function mergeHostAttrs(dst: TAttributes | null, src: TAttributes | null)
* @param value Value to add or to overwrite to `TAttributes` Only used if `marker` is not Class.
*/
export function mergeHostAttribute(
dst: TAttributes, marker: AttributeMarker, key1: string, key2: string | null,
value: string | null): void {
dst: TAttributes, marker: AttributeMarker, key1: string, key2: string|null,
value: string|null): void {
let i = 0;
// Assume that new markers will be inserted at the end.
let markerInsertPosition = dst.length;
@ -195,7 +195,7 @@ export function mergeHostAttribute(
}
return;
} else if (key2 === dst[i + 1]) {
dst[i + 2] = value !;
dst[i + 2] = value!;
return;
}
}

View File

@ -10,12 +10,13 @@ import {Injector} from '../../di/injector';
import {assertLView} from '../assert';
import {discoverLocalRefs, getComponentAtNodeIndex, getDirectivesAtNodeIndex, getLContext} from '../context_discovery';
import {NodeInjector} from '../di';
import {DebugNode, buildDebugNode} from '../instructions/lview_debug';
import {buildDebugNode, DebugNode} from '../instructions/lview_debug';
import {LContext} from '../interfaces/context';
import {DirectiveDef} from '../interfaces/definition';
import {TElementNode, TNode, TNodeProviderIndexes} from '../interfaces/node';
import {isLView} from '../interfaces/type_checks';
import {CLEANUP, CONTEXT, FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, TVIEW, T_HOST} from '../interfaces/view';
import {CLEANUP, CONTEXT, FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, T_HOST, TVIEW} from '../interfaces/view';
import {stringifyForError} from './misc_utils';
import {getLViewParent, getRootContext} from './view_traversal_utils';
import {getTNode, unwrapRNode} from './view_utils';
@ -93,14 +94,14 @@ export function getContext<T>(element: Element): T|null {
* @publicApi
* @globalApi ng
*/
export function getOwningComponent<T>(elementOrDir: Element | {}): T|null {
export function getOwningComponent<T>(elementOrDir: Element|{}): T|null {
const context = loadLContext(elementOrDir, false);
if (context === null) return null;
let lView = context.lView;
let parent: LView|null;
ngDevMode && assertLView(lView);
while (lView[HOST] === null && (parent = getLViewParent(lView) !)) {
while (lView[HOST] === null && (parent = getLViewParent(lView)!)) {
// As long as lView[HOST] is null we know we are part of sub-template such as `*ngIf`
lView = parent;
}
@ -118,7 +119,7 @@ export function getOwningComponent<T>(elementOrDir: Element | {}): T|null {
* @publicApi
* @globalApi ng
*/
export function getRootComponents(elementOrDir: Element | {}): {}[] {
export function getRootComponents(elementOrDir: Element|{}): {}[] {
return [...getRootContext(elementOrDir).components];
}
@ -132,7 +133,7 @@ export function getRootComponents(elementOrDir: Element | {}): {}[] {
* @publicApi
* @globalApi ng
*/
export function getInjector(elementOrDir: Element | {}): Injector {
export function getInjector(elementOrDir: Element|{}): Injector {
const context = loadLContext(elementOrDir, false);
if (context === null) return Injector.NULL;
@ -192,7 +193,7 @@ export function getInjectionTokens(element: Element): any[] {
* @globalApi ng
*/
export function getDirectives(element: Element): {}[] {
const context = loadLContext(element) !;
const context = loadLContext(element)!;
if (context.directives === undefined) {
context.directives = getDirectivesAtNodeIndex(context.nodeIndex, context.lView, false);
@ -250,7 +251,7 @@ export function getLocalRefs(target: {}): {[key: string]: any} {
* @globalApi ng
*/
export function getHostElement(componentOrDirective: {}): Element {
return getLContext(componentOrDirective) !.native as never as Element;
return getLContext(componentOrDirective)!.native as never as Element;
}
/**
@ -270,7 +271,7 @@ export function getRenderedText(component: any): string {
export function loadLContextFromNode(node: Node): LContext {
if (!(node instanceof Node)) throw new Error('Expecting instance of DOM Element');
return loadLContext(node) !;
return loadLContext(node)!;
}
/**

View File

@ -37,7 +37,7 @@ export function getParentInjectorView(location: RelativeInjectorLocation, startV
// <ng-template> tags or inline views, where the parent injector might live many views
// above the child injector.
while (viewOffset > 0) {
parentView = parentView[DECLARATION_VIEW] !;
parentView = parentView[DECLARATION_VIEW]!;
viewOffset--;
}
return parentView;

View File

@ -37,16 +37,18 @@ export function stringifyForError(value: any): string {
export const defaultScheduler =
(() =>
(typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame || // browser only
setTimeout // everything else
).bind(global))();
(() => (
typeof requestAnimationFrame !== 'undefined' &&
requestAnimationFrame || // browser only
setTimeout // everything else
)
.bind(global))();
/**
*
* @codeGenApi
*/
export function ɵɵresolveWindow(element: RElement & {ownerDocument: Document}) {
export function ɵɵresolveWindow(element: RElement&{ownerDocument: Document}) {
return {name: 'window', target: element.ownerDocument.defaultView};
}
@ -54,7 +56,7 @@ export function ɵɵresolveWindow(element: RElement & {ownerDocument: Document})
*
* @codeGenApi
*/
export function ɵɵresolveDocument(element: RElement & {ownerDocument: Document}) {
export function ɵɵresolveDocument(element: RElement&{ownerDocument: Document}) {
return {name: 'document', target: element.ownerDocument};
}
@ -62,7 +64,7 @@ export function ɵɵresolveDocument(element: RElement & {ownerDocument: Document
*
* @codeGenApi
*/
export function ɵɵresolveBody(element: RElement & {ownerDocument: Document}) {
export function ɵɵresolveBody(element: RElement&{ownerDocument: Document}) {
return {name: 'body', target: element.ownerDocument.body};
}
@ -85,7 +87,7 @@ export const INTERPOLATION_DELIMITER = `<60>`;
/**
* Unwrap a value which might be behind a closure (for forward declaration reasons).
*/
export function maybeUnwrapFn<T>(value: T | (() => T)): T {
export function maybeUnwrapFn<T>(value: T|(() => T)): T {
if (value instanceof Function) {
return value();
} else {

View File

@ -21,7 +21,7 @@ import {readPatchedLView} from './view_utils';
export function getLViewParent(lView: LView): LView|null {
ngDevMode && assertLView(lView);
const parent = lView[PARENT];
return isLContainer(parent) ? parent[PARENT] ! : parent;
return isLContainer(parent) ? parent[PARENT]! : parent;
}
/**
@ -30,11 +30,11 @@ export function getLViewParent(lView: LView): LView|null {
*
* @param componentOrLView any component or `LView`
*/
export function getRootView(componentOrLView: LView | {}): LView {
export function getRootView(componentOrLView: LView|{}): LView {
ngDevMode && assertDefined(componentOrLView, 'component');
let lView = isLView(componentOrLView) ? componentOrLView : readPatchedLView(componentOrLView) !;
let lView = isLView(componentOrLView) ? componentOrLView : readPatchedLView(componentOrLView)!;
while (lView && !(lView[FLAGS] & LViewFlags.IsRoot)) {
lView = getLViewParent(lView) !;
lView = getLViewParent(lView)!;
}
ngDevMode && assertLView(lView);
return lView;
@ -47,7 +47,7 @@ export function getRootView(componentOrLView: LView | {}): LView {
*
* @param viewOrComponent the `LView` or component to get the root context for.
*/
export function getRootContext(viewOrComponent: LView | {}): RootContext {
export function getRootContext(viewOrComponent: LView|{}): RootContext {
const rootView = getRootView(viewOrComponent);
ngDevMode &&
assertDefined(rootView[CONTEXT], 'RootView has no context. Perhaps it is disconnected?');

View File

@ -11,7 +11,7 @@ import {assertTNodeForLView} from '../assert';
import {ACTIVE_INDEX, ActiveIndexFlag, LContainer, TYPE} from '../interfaces/container';
import {LContext, MONKEY_PATCH_KEY_NAME} from '../interfaces/context';
import {TConstants, TNode} from '../interfaces/node';
import {RNode, isProceduralRenderer} from '../interfaces/renderer';
import {isProceduralRenderer, RNode} from '../interfaces/renderer';
import {isLContainer, isLView} from '../interfaces/type_checks';
import {FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, PARENT, PREORDER_HOOK_FLAGS, RENDERER, TData, TView} from '../interfaces/view';
@ -38,7 +38,7 @@ import {FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, PARENT, PREORDER_HOOK_FLA
* Returns `RNode`.
* @param value wrapped value of `RNode`, `LView`, `LContainer`
*/
export function unwrapRNode(value: RNode | LView | LContainer): RNode {
export function unwrapRNode(value: RNode|LView|LContainer): RNode {
while (Array.isArray(value)) {
value = value[HOST] as any;
}
@ -49,7 +49,7 @@ export function unwrapRNode(value: RNode | LView | LContainer): RNode {
* Returns `LView` or `null` if not found.
* @param value wrapped value of `RNode`, `LView`, `LContainer`
*/
export function unwrapLView(value: RNode | LView | LContainer): LView|null {
export function unwrapLView(value: RNode|LView|LContainer): LView|null {
while (Array.isArray(value)) {
// This check is same as `isLView()` but we don't call at as we don't want to call
// `Array.isArray()` twice and give JITer more work for inlining.
@ -63,7 +63,7 @@ export function unwrapLView(value: RNode | LView | LContainer): LView|null {
* Returns `LContainer` or `null` if not found.
* @param value wrapped value of `RNode`, `LView`, `LContainer`
*/
export function unwrapLContainer(value: RNode | LView | LContainer): LContainer|null {
export function unwrapLContainer(value: RNode|LView|LContainer): LContainer|null {
while (Array.isArray(value)) {
// This check is same as `isLContainer()` but we don't call at as we don't want to call
// `Array.isArray()` twice and give JITer more work for inlining.
@ -124,7 +124,7 @@ export function getTNode(tView: TView, index: number): TNode {
}
/** Retrieves a value from any `LView` or `TData`. */
export function load<T>(view: LView | TData, index: number): T {
export function load<T>(view: LView|TData, index: number): T {
ngDevMode && assertDataInRange(view, index + HEADER_OFFSET);
return view[index + HEADER_OFFSET];
}
@ -176,8 +176,7 @@ export function viewAttachedToContainer(view: LView): boolean {
}
/** Returns a constant from `TConstants` instance. */
export function getConstant<T>(consts: TConstants | null, index: number | null | undefined): T|
null {
export function getConstant<T>(consts: TConstants|null, index: number|null|undefined): T|null {
return consts === null || index == null ? null : consts[index] as unknown as T;
}

View File

@ -19,13 +19,13 @@ import {addToArray, removeFromArray} from '../util/array_utils';
import {assertDefined, assertEqual, assertGreaterThan, assertLessThan} from '../util/assert';
import {assertLContainer} from './assert';
import {NodeInjector, getParentInjectorLocation} from './di';
import {getParentInjectorLocation, NodeInjector} from './di';
import {addToViewTree, createLContainer, createLView, renderView} from './instructions/shared';
import {ActiveIndexFlag, CONTAINER_HEADER_OFFSET, LContainer, VIEW_REFS} from './interfaces/container';
import {TContainerNode, TDirectiveHostNode, TElementContainerNode, TElementNode, TNode, TNodeType, TViewNode} from './interfaces/node';
import {RComment, RElement, isProceduralRenderer} from './interfaces/renderer';
import {isProceduralRenderer, RComment, RElement} from './interfaces/renderer';
import {isComponentHost, isLContainer, isLView, isRootView} from './interfaces/type_checks';
import {DECLARATION_COMPONENT_VIEW, DECLARATION_LCONTAINER, LView, LViewFlags, PARENT, QUERIES, RENDERER, TVIEW, TView, T_HOST} from './interfaces/view';
import {DECLARATION_COMPONENT_VIEW, DECLARATION_LCONTAINER, LView, LViewFlags, PARENT, QUERIES, RENDERER, T_HOST, TVIEW, TView} from './interfaces/view';
import {assertNodeOfPossibleTypes} from './node_assert';
import {addRemoveViewFromContainer, appendChild, detachView, getBeforeNodeForView, insertView, nativeInsertBefore, nativeNextSibling, nativeParentNode, removeView} from './node_manipulation';
import {getParentInjectorTNode} from './node_util';
@ -46,7 +46,7 @@ export function injectElementRef(ElementRefToken: typeof ViewEngine_ElementRef):
return createElementRef(ElementRefToken, getPreviousOrParentTNode(), getLView());
}
let R3ElementRef: {new (native: RElement | RComment): ViewEngine_ElementRef};
let R3ElementRef: {new (native: RElement|RComment): ViewEngine_ElementRef};
/**
* Creates an ElementRef given a node.
@ -95,7 +95,7 @@ export function createTemplateRef<T>(
TemplateRefToken: typeof ViewEngine_TemplateRef, ElementRefToken: typeof ViewEngine_ElementRef,
hostTNode: TNode, hostView: LView): ViewEngine_TemplateRef<T>|null {
if (!R3TemplateRef) {
R3TemplateRef = class TemplateRef<T> extends TemplateRefToken<T> {
R3TemplateRef = class TemplateRef<T> extends TemplateRefToken<T>{
constructor(
private _declarationView: LView, private _declarationTContainer: TContainerNode,
readonly elementRef: ViewEngine_ElementRef) {
@ -138,7 +138,7 @@ export function createTemplateRef<T>(
let R3ViewContainerRef: {
new (
lContainer: LContainer, hostTNode: TElementNode | TContainerNode | TElementContainerNode,
lContainer: LContainer, hostTNode: TElementNode|TContainerNode|TElementContainerNode,
hostView: LView): ViewEngine_ViewContainerRef
};
@ -183,7 +183,9 @@ export function createContainerRef(
return createElementRef(ElementRefToken, this._hostTNode, this._hostView);
}
get injector(): Injector { return new NodeInjector(this._hostTNode, this._hostView); }
get injector(): Injector {
return new NodeInjector(this._hostTNode, this._hostView);
}
/** @deprecated No replacement */
get parentInjector(): Injector {
@ -203,10 +205,12 @@ export function createContainerRef(
}
get(index: number): viewEngine_ViewRef|null {
return this._lContainer[VIEW_REFS] !== null && this._lContainer[VIEW_REFS] ![index] || null;
return this._lContainer[VIEW_REFS] !== null && this._lContainer[VIEW_REFS]![index] || null;
}
get length(): number { return this._lContainer.length - CONTAINER_HEADER_OFFSET; }
get length(): number {
return this._lContainer.length - CONTAINER_HEADER_OFFSET;
}
createEmbeddedView<C>(templateRef: ViewEngine_TemplateRef<C>, context?: C, index?: number):
viewEngine_EmbeddedViewRef<C> {
@ -237,7 +241,7 @@ export function createContainerRef(
}
insert(viewRef: viewEngine_ViewRef, index?: number): viewEngine_ViewRef {
const lView = (viewRef as ViewRef<any>)._lView !;
const lView = (viewRef as ViewRef<any>)._lView!;
const tView = lView[TVIEW];
if (viewRef.destroyed) {
@ -259,9 +263,10 @@ export function createContainerRef(
this.detach(prevIdx);
} else {
const prevLContainer = lView[PARENT] as LContainer;
ngDevMode && assertEqual(
isLContainer(prevLContainer), true,
'An attached view should have its PARENT point to a container.');
ngDevMode &&
assertEqual(
isLContainer(prevLContainer), true,
'An attached view should have its PARENT point to a container.');
// We need to re-create a R3ViewContainerRef instance since those are not stored on
@ -281,7 +286,7 @@ export function createContainerRef(
addRemoveViewFromContainer(tView, lView, true, beforeNode);
(viewRef as ViewRef<any>).attachToViewContainerRef(this);
addToArray(this._lContainer[VIEW_REFS] !, adjustedIdx, viewRef);
addToArray(this._lContainer[VIEW_REFS]!, adjustedIdx, viewRef);
return viewRef;
}
@ -302,7 +307,7 @@ export function createContainerRef(
this.allocateContainerIfNeeded();
const adjustedIdx = this._adjustIndex(index, -1);
removeView(this._lContainer, adjustedIdx);
removeFromArray(this._lContainer[VIEW_REFS] !, adjustedIdx);
removeFromArray(this._lContainer[VIEW_REFS]!, adjustedIdx);
}
detach(index?: number): viewEngine_ViewRef|null {
@ -311,8 +316,8 @@ export function createContainerRef(
const view = detachView(this._lContainer, adjustedIdx);
const wasDetached =
view && removeFromArray(this._lContainer[VIEW_REFS] !, adjustedIdx) != null;
return wasDetached ? new ViewRef(view !) : null;
view && removeFromArray(this._lContainer[VIEW_REFS]!, adjustedIdx) != null;
return wasDetached ? new ViewRef(view!) : null;
}
private _adjustIndex(index?: number, shift: number = 0) {
@ -335,8 +340,9 @@ export function createContainerRef(
};
}
ngDevMode && assertNodeOfPossibleTypes(
hostTNode, TNodeType.Container, TNodeType.Element, TNodeType.ElementContainer);
ngDevMode &&
assertNodeOfPossibleTypes(
hostTNode, TNodeType.Container, TNodeType.Element, TNodeType.ElementContainer);
let lContainer: LContainer;
const slotValue = hostView[hostTNode.index];
@ -363,10 +369,10 @@ export function createContainerRef(
// node.
if (isRootView(hostView)) {
const renderer = hostView[RENDERER];
const hostNative = getNativeByTNode(hostTNode, hostView) !;
const hostNative = getNativeByTNode(hostTNode, hostView)!;
const parentOfHostNative = nativeParentNode(renderer, hostNative);
nativeInsertBefore(
renderer, parentOfHostNative !, commentNode, nativeNextSibling(renderer, hostNative));
renderer, parentOfHostNative!, commentNode, nativeNextSibling(renderer, hostNative));
} else {
appendChild(hostView[TVIEW], hostView, commentNode, hostTNode);
}
@ -412,7 +418,7 @@ function createViewRef(tNode: TNode, lView: LView, isPipe: boolean): ViewEngine_
const hostComponentView = lView[DECLARATION_COMPONENT_VIEW]; // look up
return new ViewRef(hostComponentView, lView);
}
return null !;
return null!;
}
/** Returns a Renderer2 (or throws when application was bootstrapped with Renderer3) */

View File

@ -10,11 +10,12 @@ import {ApplicationRef} from '../application_ref';
import {ChangeDetectorRef as viewEngine_ChangeDetectorRef} from '../change_detection/change_detector_ref';
import {ViewContainerRef as viewEngine_ViewContainerRef} from '../linker/view_container_ref';
import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, InternalViewRef as viewEngine_InternalViewRef} from '../linker/view_ref';
import {checkNoChangesInRootView, checkNoChangesInternal, detectChangesInRootView, detectChangesInternal, markViewDirty, storeCleanupFn} from './instructions/shared';
import {CONTAINER_HEADER_OFFSET} from './interfaces/container';
import {TElementNode, TNode, TNodeType, TViewNode} from './interfaces/node';
import {isLContainer} from './interfaces/type_checks';
import {CONTEXT, DECLARATION_COMPONENT_VIEW, FLAGS, HOST, LView, LViewFlags, TVIEW, TView, T_HOST} from './interfaces/view';
import {CONTEXT, DECLARATION_COMPONENT_VIEW, FLAGS, HOST, LView, LViewFlags, T_HOST, TVIEW, TView} from './interfaces/view';
import {assertNodeOfPossibleTypes} from './node_assert';
import {destroyLView, renderDetachView} from './node_manipulation';
import {getLViewParent} from './util/view_traversal_utils';
@ -28,7 +29,7 @@ import {unwrapRNode} from './util/view_utils';
export interface viewEngine_ChangeDetectorRef_interface extends viewEngine_ChangeDetectorRef {}
export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_InternalViewRef,
viewEngine_ChangeDetectorRef_interface {
viewEngine_ChangeDetectorRef_interface {
private _appRef: ApplicationRef|null = null;
private _viewContainerRef: viewEngine_ViewContainerRef|null = null;
@ -68,7 +69,9 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
*/
private _cdRefInjectingView?: LView) {}
get context(): T { return this._lView[CONTEXT] as T; }
get context(): T {
return this._lView[CONTEXT] as T;
}
get destroyed(): boolean {
return (this._lView[FLAGS] & LViewFlags.Destroyed) === LViewFlags.Destroyed;
@ -89,7 +92,9 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
destroyLView(this._lView[TVIEW], this._lView);
}
onDestroy(callback: Function) { storeCleanupFn(this._lView[TVIEW], this._lView, callback); }
onDestroy(callback: Function) {
storeCleanupFn(this._lView[TVIEW], this._lView, callback);
}
/**
* Marks a view and all of its ancestors dirty.
@ -125,7 +130,9 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
* }
* ```
*/
markForCheck(): void { markViewDirty(this._cdRefInjectingView || this._lView); }
markForCheck(): void {
markViewDirty(this._cdRefInjectingView || this._lView);
}
/**
* Detaches the view from the change detection tree.
@ -180,7 +187,9 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
* }
* ```
*/
detach(): void { this._lView[FLAGS] &= ~LViewFlags.Attached; }
detach(): void {
this._lView[FLAGS] &= ~LViewFlags.Attached;
}
/**
* Re-attaches a view to the change detection tree.
@ -238,7 +247,9 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
* }
* ```
*/
reattach(): void { this._lView[FLAGS] |= LViewFlags.Attached; }
reattach(): void {
this._lView[FLAGS] |= LViewFlags.Attached;
}
/**
* Checks the view and its children.
@ -261,7 +272,9 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
*
* See {@link ChangeDetectorRef#detach detach} for more information.
*/
detectChanges(): void { detectChangesInternal(this._lView[TVIEW], this._lView, this.context); }
detectChanges(): void {
detectChangesInternal(this._lView[TVIEW], this._lView, this.context);
}
/**
* Checks the change detector and its children, and throws if any changes are detected.
@ -269,7 +282,9 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
* This is used in development mode to verify that running change detection doesn't
* introduce other changes.
*/
checkNoChanges(): void { checkNoChangesInternal(this._lView[TVIEW], this._lView, this.context); }
checkNoChanges(): void {
checkNoChangesInternal(this._lView[TVIEW], this._lView, this.context);
}
attachToViewContainerRef(vcRef: viewEngine_ViewContainerRef) {
if (this._appRef) {
@ -293,22 +308,31 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
/** @internal */
export class RootViewRef<T> extends ViewRef<T> {
constructor(public _view: LView) { super(_view); }
constructor(public _view: LView) {
super(_view);
}
detectChanges(): void { detectChangesInRootView(this._view); }
detectChanges(): void {
detectChangesInRootView(this._view);
}
checkNoChanges(): void { checkNoChangesInRootView(this._view); }
checkNoChanges(): void {
checkNoChangesInRootView(this._view);
}
get context(): T { return null !; }
get context(): T {
return null!;
}
}
function collectNativeNodes(
tView: TView, lView: LView, tNode: TNode | null, result: any[],
tView: TView, lView: LView, tNode: TNode|null, result: any[],
isProjection: boolean = false): any[] {
while (tNode !== null) {
ngDevMode && assertNodeOfPossibleTypes(
tNode, TNodeType.Element, TNodeType.Container, TNodeType.Projection,
TNodeType.ElementContainer, TNodeType.IcuContainer);
ngDevMode &&
assertNodeOfPossibleTypes(
tNode, TNodeType.Element, TNodeType.Container, TNodeType.Projection,
TNodeType.ElementContainer, TNodeType.IcuContainer);
const lNode = lView[tNode.index];
if (lNode !== null) {
@ -337,7 +361,7 @@ function collectNativeNodes(
const componentHost = componentView[T_HOST] as TElementNode;
const parentView = getLViewParent(componentView);
let firstProjectedNode: TNode|null =
(componentHost.projection as(TNode | null)[])[tNode.projection as number];
(componentHost.projection as (TNode | null)[])[tNode.projection as number];
if (firstProjectedNode !== null && parentView !== null) {
collectNativeNodes(parentView[TVIEW], parentView, firstProjectedNode, result, true);
}