fix(core): Update types for TypeScript nullability support (#15472)
This commit is contained in:
parent
331b9f6425
commit
910c0d9ee7
|
@ -40,7 +40,7 @@ export function init(moduleRef: NgModuleRef<AppModule>) {
|
|||
|
||||
const injector = moduleRef.injector;
|
||||
appRef = injector.get(ApplicationRef);
|
||||
const numberOfChecksEl = document.getElementById('numberOfChecks');
|
||||
const numberOfChecksEl = document.getElementById('numberOfChecks') !;
|
||||
|
||||
tree = appRef.components[0].instance;
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ export class TreeNode {
|
|||
children: TreeNode[];
|
||||
|
||||
constructor(
|
||||
public value: string, public depth: number, public maxDepth: number, public left: TreeNode,
|
||||
public right: TreeNode) {
|
||||
public value: string, public depth: number, public maxDepth: number,
|
||||
public left: TreeNode|null, public right: TreeNode|null) {
|
||||
this.transitiveChildCount = Math.pow(2, (this.maxDepth - this.depth + 1)) - 1;
|
||||
this.children = this.left ? [this.left, this.right] : [];
|
||||
this.children = this.left ? [this.left, this.right !] : [];
|
||||
}
|
||||
|
||||
// Needed for Polymer as it does not support ternary nor modulo operator
|
||||
|
|
|
@ -35,7 +35,7 @@ export function getStringParameter(name: string) {
|
|||
}
|
||||
|
||||
export function bindAction(selector: string, callback: () => void) {
|
||||
document.querySelector(selector).addEventListener('click', callback);
|
||||
document.querySelector(selector) !.addEventListener('click', callback);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ export function profile(create: () => void, destroy: () => void, name: string) {
|
|||
function urlParamsToForm() {
|
||||
const regex = /(\w+)=(\w+)/g;
|
||||
const search = decodeURIComponent(location.search);
|
||||
let match: any[];
|
||||
let match: any[]|null;
|
||||
while (match = regex.exec(search)) {
|
||||
const name = match[1];
|
||||
const value = match[2];
|
||||
|
|
|
@ -98,7 +98,7 @@ export interface AnimationStyleMetadata extends AnimationMetadata {
|
|||
*/
|
||||
export interface AnimationAnimateMetadata extends AnimationMetadata {
|
||||
timings: string|number|AnimateTimings;
|
||||
styles: AnimationStyleMetadata|AnimationKeyframesSequenceMetadata;
|
||||
styles: AnimationStyleMetadata|AnimationKeyframesSequenceMetadata|null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,8 +218,8 @@ export function trigger(name: string, definitions: AnimationMetadata[]): Animati
|
|||
* @experimental Animation support is experimental.
|
||||
*/
|
||||
export function animate(
|
||||
timings: string | number, styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata =
|
||||
null): AnimationAnimateMetadata {
|
||||
timings: string | number, styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata |
|
||||
null = null): AnimationAnimateMetadata {
|
||||
return {type: AnimationMetadataType.Animate, styles: styles, timings: timings};
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ function getSourcePositionForStack(stack: string): {source: string, line: number
|
|||
const htmlLocations = stack
|
||||
.split('\n')
|
||||
// e.g. at View_MyComp_0 (...html:153:40)
|
||||
.map(line => /\((.*\.html):(\d+):(\d+)/.exec(line))
|
||||
.map(line => /\((.*\.html):(\d+):(\d+)/.exec(line) !)
|
||||
.filter(match => !!match)
|
||||
.map(match => ({
|
||||
source: match[1],
|
||||
|
|
|
@ -67,9 +67,9 @@ function codeGenTest() {
|
|||
angularCompilerOptions: config.ngOptions,
|
||||
|
||||
// i18n options.
|
||||
i18nFormat: null,
|
||||
i18nFile: null,
|
||||
locale: null,
|
||||
i18nFormat: undefined,
|
||||
i18nFile: undefined,
|
||||
locale: undefined,
|
||||
|
||||
readResource: (fileName: string) => {
|
||||
readResources.push(fileName);
|
||||
|
@ -131,8 +131,8 @@ function i18nTest() {
|
|||
compilerOptions: config.parsed.options, program, host,
|
||||
angularCompilerOptions: config.ngOptions,
|
||||
i18nFormat: 'xlf',
|
||||
locale: null,
|
||||
outFile: null,
|
||||
locale: undefined,
|
||||
outFile: undefined,
|
||||
readResource: (fileName: string) => {
|
||||
readResources.push(fileName);
|
||||
return hostContext.readResource(fileName);
|
||||
|
|
|
@ -34,7 +34,8 @@ function main() {
|
|||
if (/.*\/node_modules\/.*/.test(fileName) && !/.*ngsummary\.json$/.test(fileName) &&
|
||||
!/package\.json$/.test(fileName)) {
|
||||
// Only allow to read summaries and package.json files from node_modules
|
||||
return null;
|
||||
// TODO (mhevery): Fix this. TypeScript.d.ts does not allow returning null.
|
||||
return null !;
|
||||
}
|
||||
readFiles.push(path.relative(basePath, fileName));
|
||||
return super.readFile(fileName);
|
||||
|
|
|
@ -13,7 +13,7 @@ import {platformServer} from '@angular/platform-server';
|
|||
import {MainModule} from '../src/module';
|
||||
import {MainModuleNgFactory} from '../src/module.ngfactory';
|
||||
|
||||
let mainModuleRef: NgModuleRef<MainModule> = null;
|
||||
let mainModuleRef: NgModuleRef<MainModule> = null !;
|
||||
beforeEach((done) => {
|
||||
platformServer().bootstrapModuleFactory(MainModuleNgFactory).then((moduleRef: any) => {
|
||||
mainModuleRef = moduleRef;
|
||||
|
@ -29,5 +29,5 @@ export function createComponent<C>(comp: {new (...args: any[]): C}): ComponentFi
|
|||
const moduleRef = createModule();
|
||||
const compRef =
|
||||
moduleRef.componentFactoryResolver.resolveComponentFactory(comp).create(moduleRef.injector);
|
||||
return new ComponentFixture(compRef, null, null);
|
||||
return new ComponentFixture(compRef, null, false);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
"target": "es5",
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "node",
|
||||
"rootDir": "",
|
||||
"declaration": true,
|
||||
|
|
|
@ -32,9 +32,9 @@ export interface NgTools_InternalApi_NG2_CodeGen_Options {
|
|||
angularCompilerOptions: AngularCompilerOptions;
|
||||
|
||||
// i18n options.
|
||||
i18nFormat: string;
|
||||
i18nFile: string;
|
||||
locale: string;
|
||||
i18nFormat?: string;
|
||||
i18nFile?: string;
|
||||
locale?: string;
|
||||
|
||||
readResource: (fileName: string) => Promise<string>;
|
||||
|
||||
|
@ -58,7 +58,7 @@ export interface NgTools_InternalApi_NG2_ExtractI18n_Options {
|
|||
program: ts.Program;
|
||||
host: ts.CompilerHost;
|
||||
angularCompilerOptions: AngularCompilerOptions;
|
||||
i18nFormat: string;
|
||||
i18nFormat?: string;
|
||||
readResource: (fileName: string) => Promise<string>;
|
||||
// Every new property under this line should be optional.
|
||||
locale?: string;
|
||||
|
|
|
@ -644,8 +644,8 @@ class ViewBuilder implements TemplateAstVisitor, LocalResolver {
|
|||
return EventHandlerVars.event;
|
||||
}
|
||||
let currViewExpr: o.Expression = VIEW_VAR;
|
||||
for (let currBuilder: ViewBuilder = this; currBuilder;
|
||||
currBuilder = currBuilder.parent, currViewExpr = currViewExpr.prop('parent')) {
|
||||
for (let currBuilder: ViewBuilder = this; currBuilder; currBuilder = currBuilder.parent,
|
||||
currViewExpr = currViewExpr.prop('parent').cast(o.DYNAMIC_TYPE)) {
|
||||
// check references
|
||||
const refNodeIndex = currBuilder.refNodeIndices[name];
|
||||
if (refNodeIndex != null) {
|
||||
|
@ -717,7 +717,7 @@ class ViewBuilder implements TemplateAstVisitor, LocalResolver {
|
|||
let compBuilder: ViewBuilder = this;
|
||||
while (compBuilder.parent) {
|
||||
compBuilder = compBuilder.parent;
|
||||
compViewExpr = compViewExpr.prop('parent');
|
||||
compViewExpr = compViewExpr.prop('parent').cast(o.DYNAMIC_TYPE);
|
||||
}
|
||||
const pipeNodeIndex = compBuilder.purePipeNodeIndices[name];
|
||||
const pipeValueExpr: o.Expression =
|
||||
|
|
|
@ -62,7 +62,7 @@ export interface AnimationStyleMetadata extends AnimationMetadata {
|
|||
*/
|
||||
export interface AnimationAnimateMetadata extends AnimationMetadata {
|
||||
timings: string|number|AnimateTimings;
|
||||
styles: AnimationStyleMetadata|AnimationKeyframesSequenceMetadata;
|
||||
styles: AnimationStyleMetadata|AnimationKeyframesSequenceMetadata|null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,8 +86,8 @@ export function trigger(name: string, definitions: AnimationMetadata[]): Animati
|
|||
* @deprecated This symbol has moved. Please Import from @angular/animations instead!
|
||||
*/
|
||||
export function animate(
|
||||
timings: string | number, styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata =
|
||||
null): AnimationAnimateMetadata {
|
||||
timings: string | number, styles?: AnimationStyleMetadata |
|
||||
AnimationKeyframesSequenceMetadata): AnimationAnimateMetadata {
|
||||
return _animate(timings, styles);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ export function createPlatform(injector: Injector): PlatformRef {
|
|||
* @experimental APIs related to application bootstrap are currently under review.
|
||||
*/
|
||||
export function createPlatformFactory(
|
||||
parentPlatformFactory: (extraProviders?: Provider[]) => PlatformRef, name: string,
|
||||
parentPlatformFactory: ((extraProviders?: Provider[]) => PlatformRef) | null, name: string,
|
||||
providers: Provider[] = []): (extraProviders?: Provider[]) => PlatformRef {
|
||||
const marker = new InjectionToken(`Platform: ${name}`);
|
||||
return (extraProviders: Provider[] = []) => {
|
||||
|
@ -153,7 +153,7 @@ export function destroyPlatform(): void {
|
|||
*
|
||||
* @experimental APIs related to application bootstrap are currently under review.
|
||||
*/
|
||||
export function getPlatform(): PlatformRef {
|
||||
export function getPlatform(): PlatformRef|null {
|
||||
return _platform && !_platform.destroyed ? _platform : null;
|
||||
}
|
||||
|
||||
|
@ -278,10 +278,10 @@ export class PlatformRef_ extends PlatformRef {
|
|||
}
|
||||
|
||||
bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>): Promise<NgModuleRef<M>> {
|
||||
return this._bootstrapModuleFactoryWithZone(moduleFactory, null);
|
||||
return this._bootstrapModuleFactoryWithZone(moduleFactory);
|
||||
}
|
||||
|
||||
private _bootstrapModuleFactoryWithZone<M>(moduleFactory: NgModuleFactory<M>, ngZone: NgZone):
|
||||
private _bootstrapModuleFactoryWithZone<M>(moduleFactory: NgModuleFactory<M>, ngZone?: NgZone):
|
||||
Promise<NgModuleRef<M>> {
|
||||
// Note: We need to create the NgZone _before_ we instantiate the module,
|
||||
// as instantiating the module creates some providers eagerly.
|
||||
|
@ -299,7 +299,7 @@ export class PlatformRef_ extends PlatformRef {
|
|||
throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
|
||||
}
|
||||
moduleRef.onDestroy(() => remove(this._modules, moduleRef));
|
||||
ngZone.onError.subscribe({next: (error: any) => { exceptionHandler.handleError(error); }});
|
||||
ngZone !.onError.subscribe({next: (error: any) => { exceptionHandler.handleError(error); }});
|
||||
return _callAndReportToErrorHandler(exceptionHandler, () => {
|
||||
const initStatus: ApplicationInitStatus = moduleRef.injector.get(ApplicationInitStatus);
|
||||
return initStatus.donePromise.then(() => {
|
||||
|
@ -312,12 +312,12 @@ export class PlatformRef_ extends PlatformRef {
|
|||
|
||||
bootstrapModule<M>(moduleType: Type<M>, compilerOptions: CompilerOptions|CompilerOptions[] = []):
|
||||
Promise<NgModuleRef<M>> {
|
||||
return this._bootstrapModuleWithZone(moduleType, compilerOptions, null);
|
||||
return this._bootstrapModuleWithZone(moduleType, compilerOptions);
|
||||
}
|
||||
|
||||
private _bootstrapModuleWithZone<M>(
|
||||
moduleType: Type<M>, compilerOptions: CompilerOptions|CompilerOptions[] = [],
|
||||
ngZone: NgZone = null): Promise<NgModuleRef<M>> {
|
||||
ngZone?: NgZone): Promise<NgModuleRef<M>> {
|
||||
const compilerFactory: CompilerFactory = this.injector.get(CompilerFactory);
|
||||
const compiler = compilerFactory.createCompiler(
|
||||
Array.isArray(compilerOptions) ? compilerOptions : [compilerOptions]);
|
||||
|
@ -500,7 +500,8 @@ export class ApplicationRef_ extends ApplicationRef {
|
|||
if (componentOrFactory instanceof ComponentFactory) {
|
||||
componentFactory = componentOrFactory;
|
||||
} else {
|
||||
componentFactory = this._componentFactoryResolver.resolveComponentFactory(componentOrFactory);
|
||||
componentFactory =
|
||||
this._componentFactoryResolver.resolveComponentFactory(componentOrFactory) !;
|
||||
}
|
||||
this._rootComponentTypes.push(componentFactory.componentType);
|
||||
|
||||
|
|
|
@ -15,16 +15,15 @@ import {IterableChangeRecord, IterableChanges, IterableDiffer, IterableDifferFac
|
|||
|
||||
export class DefaultIterableDifferFactory implements IterableDifferFactory {
|
||||
constructor() {}
|
||||
supports(obj: Object): boolean { return isListLikeIterable(obj); }
|
||||
supports(obj: Object|null|undefined): boolean { return isListLikeIterable(obj); }
|
||||
|
||||
create<V>(trackByFn?: TrackByFunction<any>): DefaultIterableDiffer<V>;
|
||||
create<V>(trackByFn?: TrackByFunction<V>): DefaultIterableDiffer<V>;
|
||||
|
||||
/**
|
||||
* @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
|
||||
*/
|
||||
create<V>(
|
||||
cdRefOrTrackBy?: ChangeDetectorRef|TrackByFunction<any>,
|
||||
trackByFn?: TrackByFunction<any>): DefaultIterableDiffer<V> {
|
||||
create<V>(cdRefOrTrackBy?: ChangeDetectorRef|TrackByFunction<V>, trackByFn?: TrackByFunction<V>):
|
||||
DefaultIterableDiffer<V> {
|
||||
return new DefaultIterableDiffer<V>(trackByFn || <TrackByFunction<any>>cdRefOrTrackBy);
|
||||
}
|
||||
}
|
||||
|
@ -35,27 +34,28 @@ const trackByIdentity = (index: number, item: any) => item;
|
|||
* @deprecated v4.0.0 - Should not be part of public API.
|
||||
*/
|
||||
export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChanges<V> {
|
||||
private _length: number = null;
|
||||
private _collection: NgIterable<V> = null;
|
||||
private _length: number = 0;
|
||||
private _collection: NgIterable<V>|null = null;
|
||||
// Keeps track of the used records at any point in time (during & across `_check()` calls)
|
||||
private _linkedRecords: _DuplicateMap<V> = null;
|
||||
private _linkedRecords: _DuplicateMap<V>|null = null;
|
||||
// Keeps track of the removed records at any point in time during `_check()` calls.
|
||||
private _unlinkedRecords: _DuplicateMap<V> = null;
|
||||
private _previousItHead: IterableChangeRecord_<V> = null;
|
||||
private _itHead: IterableChangeRecord_<V> = null;
|
||||
private _itTail: IterableChangeRecord_<V> = null;
|
||||
private _additionsHead: IterableChangeRecord_<V> = null;
|
||||
private _additionsTail: IterableChangeRecord_<V> = null;
|
||||
private _movesHead: IterableChangeRecord_<V> = null;
|
||||
private _movesTail: IterableChangeRecord_<V> = null;
|
||||
private _removalsHead: IterableChangeRecord_<V> = null;
|
||||
private _removalsTail: IterableChangeRecord_<V> = null;
|
||||
private _unlinkedRecords: _DuplicateMap<V>|null = null;
|
||||
private _previousItHead: IterableChangeRecord_<V>|null = null;
|
||||
private _itHead: IterableChangeRecord_<V>|null = null;
|
||||
private _itTail: IterableChangeRecord_<V>|null = null;
|
||||
private _additionsHead: IterableChangeRecord_<V>|null = null;
|
||||
private _additionsTail: IterableChangeRecord_<V>|null = null;
|
||||
private _movesHead: IterableChangeRecord_<V>|null = null;
|
||||
private _movesTail: IterableChangeRecord_<V>|null = null;
|
||||
private _removalsHead: IterableChangeRecord_<V>|null = null;
|
||||
private _removalsTail: IterableChangeRecord_<V>|null = null;
|
||||
// Keeps track of records where custom track by is the same, but item identity has changed
|
||||
private _identityChangesHead: IterableChangeRecord_<V> = null;
|
||||
private _identityChangesTail: IterableChangeRecord_<V> = null;
|
||||
private _identityChangesHead: IterableChangeRecord_<V>|null = null;
|
||||
private _identityChangesTail: IterableChangeRecord_<V>|null = null;
|
||||
private _trackByFn: TrackByFunction<V>
|
||||
|
||||
constructor(private _trackByFn?: TrackByFunction<V>) {
|
||||
this._trackByFn = this._trackByFn || trackByIdentity;
|
||||
constructor(trackByFn?: TrackByFunction<V>) {
|
||||
this._trackByFn = trackByFn || trackByIdentity;
|
||||
}
|
||||
|
||||
get collection() { return this._collection; }
|
||||
|
@ -63,25 +63,27 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
get length(): number { return this._length; }
|
||||
|
||||
forEachItem(fn: (record: IterableChangeRecord_<V>) => void) {
|
||||
let record: IterableChangeRecord_<V>;
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
for (record = this._itHead; record !== null; record = record._next) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachOperation(
|
||||
fn: (item: IterableChangeRecord_<V>, previousIndex: number, currentIndex: number) => void) {
|
||||
fn: (item: IterableChangeRecord<V>, previousIndex: number|null, currentIndex: number|null) =>
|
||||
void) {
|
||||
let nextIt = this._itHead;
|
||||
let nextRemove = this._removalsHead;
|
||||
let addRemoveOffset = 0;
|
||||
let moveOffsets: number[] = null;
|
||||
let moveOffsets: number[]|null = null;
|
||||
while (nextIt || nextRemove) {
|
||||
// Figure out which is the next record to process
|
||||
// Order: remove, add, move
|
||||
const record = !nextRemove ||
|
||||
const record: IterableChangeRecord<V> = !nextRemove ||
|
||||
nextIt &&
|
||||
nextIt.currentIndex < getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ?
|
||||
nextIt :
|
||||
nextIt.currentIndex ! <
|
||||
getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ?
|
||||
nextIt ! :
|
||||
nextRemove;
|
||||
const adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
|
||||
const currentIndex = record.currentIndex;
|
||||
|
@ -91,14 +93,14 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
addRemoveOffset--;
|
||||
nextRemove = nextRemove._nextRemoved;
|
||||
} else {
|
||||
nextIt = nextIt._next;
|
||||
nextIt = nextIt !._next;
|
||||
if (record.previousIndex == null) {
|
||||
addRemoveOffset++;
|
||||
} else {
|
||||
// INVARIANT: currentIndex < previousIndex
|
||||
if (!moveOffsets) moveOffsets = [];
|
||||
const localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
|
||||
const localCurrentIndex = currentIndex - addRemoveOffset;
|
||||
const localCurrentIndex = currentIndex ! - addRemoveOffset;
|
||||
if (localMovePreviousIndex != localCurrentIndex) {
|
||||
for (let i = 0; i < localMovePreviousIndex; i++) {
|
||||
const offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
|
||||
|
@ -120,41 +122,41 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
}
|
||||
|
||||
forEachPreviousItem(fn: (record: IterableChangeRecord_<V>) => void) {
|
||||
let record: IterableChangeRecord_<V>;
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachAddedItem(fn: (record: IterableChangeRecord_<V>) => void) {
|
||||
let record: IterableChangeRecord_<V>;
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachMovedItem(fn: (record: IterableChangeRecord_<V>) => void) {
|
||||
let record: IterableChangeRecord_<V>;
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
for (record = this._movesHead; record !== null; record = record._nextMoved) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachRemovedItem(fn: (record: IterableChangeRecord_<V>) => void) {
|
||||
let record: IterableChangeRecord_<V>;
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachIdentityChange(fn: (record: IterableChangeRecord_<V>) => void) {
|
||||
let record: IterableChangeRecord_<V>;
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
diff(collection: NgIterable<V>): DefaultIterableDiffer<V> {
|
||||
diff(collection: NgIterable<V>): DefaultIterableDiffer<V>|null {
|
||||
if (collection == null) collection = [];
|
||||
if (!isListLikeIterable(collection)) {
|
||||
throw new Error(
|
||||
|
@ -174,7 +176,7 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
check(collection: NgIterable<V>): boolean {
|
||||
this._reset();
|
||||
|
||||
let record: IterableChangeRecord_<V> = this._itHead;
|
||||
let record: IterableChangeRecord_<V>|null = this._itHead;
|
||||
let mayBeDirty: boolean = false;
|
||||
let index: number;
|
||||
let item: V;
|
||||
|
@ -241,8 +243,8 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
*/
|
||||
_reset() {
|
||||
if (this.isDirty) {
|
||||
let record: IterableChangeRecord_<V>;
|
||||
let nextRecord: IterableChangeRecord_<V>;
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
let nextRecord: IterableChangeRecord_<V>|null;
|
||||
|
||||
for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
|
||||
record._nextPrevious = record._next;
|
||||
|
@ -276,15 +278,15 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
*
|
||||
* @internal
|
||||
*/
|
||||
_mismatch(record: IterableChangeRecord_<V>, item: V, itemTrackBy: any, index: number):
|
||||
_mismatch(record: IterableChangeRecord_<V>|null, item: V, itemTrackBy: any, index: number):
|
||||
IterableChangeRecord_<V> {
|
||||
// The previous record after which we will append the current one.
|
||||
let previousRecord: IterableChangeRecord_<V>;
|
||||
|
||||
if (record === null) {
|
||||
previousRecord = this._itTail;
|
||||
previousRecord = this._itTail !;
|
||||
} else {
|
||||
previousRecord = record._prev;
|
||||
previousRecord = record._prev !;
|
||||
// Remove the record from the collection since we know it does not match the item.
|
||||
this._remove(record);
|
||||
}
|
||||
|
@ -299,7 +301,7 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
this._moveAfter(record, previousRecord, index);
|
||||
} else {
|
||||
// Never seen it, check evicted list.
|
||||
record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy);
|
||||
record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
|
||||
if (record !== null) {
|
||||
// It is an item which we have evicted earlier: reinsert it back into the list.
|
||||
// But first we need to check if identity changed, so we can update in view if necessary
|
||||
|
@ -344,10 +346,10 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
*/
|
||||
_verifyReinsertion(record: IterableChangeRecord_<V>, item: V, itemTrackBy: any, index: number):
|
||||
IterableChangeRecord_<V> {
|
||||
let reinsertRecord: IterableChangeRecord_<V> =
|
||||
this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy);
|
||||
let reinsertRecord: IterableChangeRecord_<V>|null =
|
||||
this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
|
||||
if (reinsertRecord !== null) {
|
||||
record = this._reinsertAfter(reinsertRecord, record._prev, index);
|
||||
record = this._reinsertAfter(reinsertRecord, record._prev !, index);
|
||||
} else if (record.currentIndex != index) {
|
||||
record.currentIndex = index;
|
||||
this._addToMoves(record, index);
|
||||
|
@ -362,10 +364,10 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
*
|
||||
* @internal
|
||||
*/
|
||||
_truncate(record: IterableChangeRecord_<V>) {
|
||||
_truncate(record: IterableChangeRecord_<V>|null) {
|
||||
// Anything after that needs to be removed;
|
||||
while (record !== null) {
|
||||
const nextRecord: IterableChangeRecord_<V> = record._next;
|
||||
const nextRecord: IterableChangeRecord_<V>|null = record._next;
|
||||
this._addToRemovals(this._unlink(record));
|
||||
record = nextRecord;
|
||||
}
|
||||
|
@ -452,7 +454,8 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
// assert(record._next === null);
|
||||
// assert(record._prev === null);
|
||||
|
||||
const next: IterableChangeRecord_<V> = prevRecord === null ? this._itHead : prevRecord._next;
|
||||
const next: IterableChangeRecord_<V>|null =
|
||||
prevRecord === null ? this._itHead : prevRecord._next;
|
||||
// todo(vicb)
|
||||
// assert(next != record);
|
||||
// assert(prevRecord != record);
|
||||
|
@ -599,29 +602,29 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
|||
* @stable
|
||||
*/
|
||||
export class IterableChangeRecord_<V> implements IterableChangeRecord<V> {
|
||||
currentIndex: number = null;
|
||||
previousIndex: number = null;
|
||||
currentIndex: number|null = null;
|
||||
previousIndex: number|null = null;
|
||||
|
||||
/** @internal */
|
||||
_nextPrevious: IterableChangeRecord_<V> = null;
|
||||
_nextPrevious: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_prev: IterableChangeRecord_<V> = null;
|
||||
_prev: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_next: IterableChangeRecord_<V> = null;
|
||||
_next: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_prevDup: IterableChangeRecord_<V> = null;
|
||||
_prevDup: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_nextDup: IterableChangeRecord_<V> = null;
|
||||
_nextDup: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_prevRemoved: IterableChangeRecord_<V> = null;
|
||||
_prevRemoved: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_nextRemoved: IterableChangeRecord_<V> = null;
|
||||
_nextRemoved: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_nextAdded: IterableChangeRecord_<V> = null;
|
||||
_nextAdded: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_nextMoved: IterableChangeRecord_<V> = null;
|
||||
_nextMoved: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_nextIdentityChange: IterableChangeRecord_<V> = null;
|
||||
_nextIdentityChange: IterableChangeRecord_<V>|null = null;
|
||||
|
||||
|
||||
constructor(public item: V, public trackById: any) {}
|
||||
|
@ -636,9 +639,9 @@ export class IterableChangeRecord_<V> implements IterableChangeRecord<V> {
|
|||
// A linked list of CollectionChangeRecords with the same IterableChangeRecord_.item
|
||||
class _DuplicateItemRecordList<V> {
|
||||
/** @internal */
|
||||
_head: IterableChangeRecord_<V> = null;
|
||||
_head: IterableChangeRecord_<V>|null = null;
|
||||
/** @internal */
|
||||
_tail: IterableChangeRecord_<V> = null;
|
||||
_tail: IterableChangeRecord_<V>|null = null;
|
||||
|
||||
/**
|
||||
* Append the record to the list of duplicates.
|
||||
|
@ -654,7 +657,7 @@ class _DuplicateItemRecordList<V> {
|
|||
// todo(vicb)
|
||||
// assert(record.item == _head.item ||
|
||||
// record.item is num && record.item.isNaN && _head.item is num && _head.item.isNaN);
|
||||
this._tail._nextDup = record;
|
||||
this._tail !._nextDup = record;
|
||||
record._prevDup = this._tail;
|
||||
record._nextDup = null;
|
||||
this._tail = record;
|
||||
|
@ -663,8 +666,8 @@ class _DuplicateItemRecordList<V> {
|
|||
|
||||
// Returns a IterableChangeRecord_ having IterableChangeRecord_.trackById == trackById and
|
||||
// IterableChangeRecord_.currentIndex >= afterIndex
|
||||
get(trackById: any, afterIndex: number): IterableChangeRecord_<V> {
|
||||
let record: IterableChangeRecord_<V>;
|
||||
get(trackById: any, afterIndex: number|null): IterableChangeRecord_<V>|null {
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
for (record = this._head; record !== null; record = record._nextDup) {
|
||||
if ((afterIndex === null || afterIndex < record.currentIndex) &&
|
||||
looseIdentical(record.trackById, trackById)) {
|
||||
|
@ -689,8 +692,8 @@ class _DuplicateItemRecordList<V> {
|
|||
// return false;
|
||||
//});
|
||||
|
||||
const prev: IterableChangeRecord_<V> = record._prevDup;
|
||||
const next: IterableChangeRecord_<V> = record._nextDup;
|
||||
const prev: IterableChangeRecord_<V>|null = record._prevDup;
|
||||
const next: IterableChangeRecord_<V>|null = record._nextDup;
|
||||
if (prev === null) {
|
||||
this._head = next;
|
||||
} else {
|
||||
|
@ -726,7 +729,7 @@ class _DuplicateMap<V> {
|
|||
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
|
||||
* have any more `a`s needs to return the last `a` not the first or second.
|
||||
*/
|
||||
get(trackById: any, afterIndex: number = null): IterableChangeRecord_<V> {
|
||||
get(trackById: any, afterIndex: number|null): IterableChangeRecord_<V>|null {
|
||||
const key = trackById;
|
||||
const recordList = this.map.get(key);
|
||||
return recordList ? recordList.get(trackById, afterIndex) : null;
|
||||
|
@ -739,7 +742,7 @@ class _DuplicateMap<V> {
|
|||
*/
|
||||
remove(record: IterableChangeRecord_<V>): IterableChangeRecord_<V> {
|
||||
const key = record.trackById;
|
||||
const recordList: _DuplicateItemRecordList<V> = this.map.get(key);
|
||||
const recordList: _DuplicateItemRecordList<V> = this.map.get(key) !;
|
||||
// Remove the list of duplicates when it gets empty
|
||||
if (recordList.remove(record)) {
|
||||
this.map.delete(key);
|
||||
|
@ -754,7 +757,8 @@ class _DuplicateMap<V> {
|
|||
toString(): string { return '_DuplicateMap(' + stringify(this.map) + ')'; }
|
||||
}
|
||||
|
||||
function getPreviousIndex(item: any, addRemoveOffset: number, moveOffsets: number[]): number {
|
||||
function getPreviousIndex(
|
||||
item: any, addRemoveOffset: number, moveOffsets: number[] | null): number {
|
||||
const previousIndex = item.previousIndex;
|
||||
if (previousIndex === null) return previousIndex;
|
||||
let moveOffset = 0;
|
||||
|
|
|
@ -28,21 +28,16 @@ export class DefaultKeyValueDifferFactory<K, V> implements KeyValueDifferFactory
|
|||
|
||||
export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyValueChanges<K, V> {
|
||||
private _records = new Map<K, KeyValueChangeRecord_<K, V>>();
|
||||
|
||||
private _mapHead: KeyValueChangeRecord_<K, V> = null;
|
||||
private _mapHead: KeyValueChangeRecord_<K, V>|null = null;
|
||||
// _appendAfter is used in the check loop
|
||||
private _appendAfter: KeyValueChangeRecord_<K, V> = null;
|
||||
|
||||
private _previousMapHead: KeyValueChangeRecord_<K, V> = null;
|
||||
|
||||
private _changesHead: KeyValueChangeRecord_<K, V> = null;
|
||||
private _changesTail: KeyValueChangeRecord_<K, V> = null;
|
||||
|
||||
private _additionsHead: KeyValueChangeRecord_<K, V> = null;
|
||||
private _additionsTail: KeyValueChangeRecord_<K, V> = null;
|
||||
|
||||
private _removalsHead: KeyValueChangeRecord_<K, V> = null;
|
||||
private _removalsTail: KeyValueChangeRecord_<K, V> = null;
|
||||
private _appendAfter: KeyValueChangeRecord_<K, V>|null = null;
|
||||
private _previousMapHead: KeyValueChangeRecord_<K, V>|null = null;
|
||||
private _changesHead: KeyValueChangeRecord_<K, V>|null = null;
|
||||
private _changesTail: KeyValueChangeRecord_<K, V>|null = null;
|
||||
private _additionsHead: KeyValueChangeRecord_<K, V>|null = null;
|
||||
private _additionsTail: KeyValueChangeRecord_<K, V>|null = null;
|
||||
private _removalsHead: KeyValueChangeRecord_<K, V>|null = null;
|
||||
private _removalsTail: KeyValueChangeRecord_<K, V>|null = null;
|
||||
|
||||
get isDirty(): boolean {
|
||||
return this._additionsHead !== null || this._changesHead !== null ||
|
||||
|
@ -50,41 +45,41 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
|
|||
}
|
||||
|
||||
forEachItem(fn: (r: KeyValueChangeRecord<K, V>) => void) {
|
||||
let record: KeyValueChangeRecord_<K, V>;
|
||||
let record: KeyValueChangeRecord_<K, V>|null;
|
||||
for (record = this._mapHead; record !== null; record = record._next) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachPreviousItem(fn: (r: KeyValueChangeRecord<K, V>) => void) {
|
||||
let record: KeyValueChangeRecord_<K, V>;
|
||||
let record: KeyValueChangeRecord_<K, V>|null;
|
||||
for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachChangedItem(fn: (r: KeyValueChangeRecord<K, V>) => void) {
|
||||
let record: KeyValueChangeRecord_<K, V>;
|
||||
let record: KeyValueChangeRecord_<K, V>|null;
|
||||
for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachAddedItem(fn: (r: KeyValueChangeRecord<K, V>) => void) {
|
||||
let record: KeyValueChangeRecord_<K, V>;
|
||||
let record: KeyValueChangeRecord_<K, V>|null;
|
||||
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachRemovedItem(fn: (r: KeyValueChangeRecord<K, V>) => void) {
|
||||
let record: KeyValueChangeRecord_<K, V>;
|
||||
let record: KeyValueChangeRecord_<K, V>|null;
|
||||
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
diff(map: Map<any, any>|{[k: string]: any}): any {
|
||||
diff(map?: Map<any, any>|{[k: string]: any}|null): any {
|
||||
if (!map) {
|
||||
map = new Map();
|
||||
} else if (!(map instanceof Map || isJsObject(map))) {
|
||||
|
@ -209,7 +204,7 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
|
|||
/** @internal */
|
||||
_reset() {
|
||||
if (this.isDirty) {
|
||||
let record: KeyValueChangeRecord_<K, V>;
|
||||
let record: KeyValueChangeRecord_<K, V>|null;
|
||||
// let `_previousMapHead` contain the state of the map before the changes
|
||||
this._previousMapHead = this._mapHead;
|
||||
for (record = this._previousMapHead; record !== null; record = record._next) {
|
||||
|
@ -244,7 +239,7 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
|
|||
if (this._additionsHead === null) {
|
||||
this._additionsHead = this._additionsTail = record;
|
||||
} else {
|
||||
this._additionsTail._nextAdded = record;
|
||||
this._additionsTail !._nextAdded = record;
|
||||
this._additionsTail = record;
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +248,7 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
|
|||
if (this._changesHead === null) {
|
||||
this._changesHead = this._changesTail = record;
|
||||
} else {
|
||||
this._changesTail._nextChanged = record;
|
||||
this._changesTail !._nextChanged = record;
|
||||
this._changesTail = record;
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +259,7 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
|
|||
const changes: any[] = [];
|
||||
const additions: any[] = [];
|
||||
const removals: any[] = [];
|
||||
let record: KeyValueChangeRecord_<K, V>;
|
||||
let record: KeyValueChangeRecord_<K, V>|null;
|
||||
|
||||
for (record = this._mapHead; record !== null; record = record._next) {
|
||||
items.push(stringify(record));
|
||||
|
@ -304,21 +299,21 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
|
|||
* @stable
|
||||
*/
|
||||
class KeyValueChangeRecord_<K, V> implements KeyValueChangeRecord<K, V> {
|
||||
previousValue: V = null;
|
||||
currentValue: V = null;
|
||||
previousValue: V|null = null;
|
||||
currentValue: V|null = null;
|
||||
|
||||
/** @internal */
|
||||
_nextPrevious: KeyValueChangeRecord_<K, V> = null;
|
||||
_nextPrevious: KeyValueChangeRecord_<K, V>|null = null;
|
||||
/** @internal */
|
||||
_next: KeyValueChangeRecord_<K, V> = null;
|
||||
_next: KeyValueChangeRecord_<K, V>|null = null;
|
||||
/** @internal */
|
||||
_prev: KeyValueChangeRecord_<K, V> = null;
|
||||
_prev: KeyValueChangeRecord_<K, V>|null = null;
|
||||
/** @internal */
|
||||
_nextAdded: KeyValueChangeRecord_<K, V> = null;
|
||||
_nextAdded: KeyValueChangeRecord_<K, V>|null = null;
|
||||
/** @internal */
|
||||
_nextRemoved: KeyValueChangeRecord_<K, V> = null;
|
||||
_nextRemoved: KeyValueChangeRecord_<K, V>|null = null;
|
||||
/** @internal */
|
||||
_nextChanged: KeyValueChangeRecord_<K, V> = null;
|
||||
_nextChanged: KeyValueChangeRecord_<K, V>|null = null;
|
||||
|
||||
constructor(public key: K) {}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export interface IterableDiffer<V> {
|
|||
* @returns an object describing the difference. The return value is only valid until the next
|
||||
* `diff()` invocation.
|
||||
*/
|
||||
diff(object: NgIterable<V>): IterableChanges<V>;
|
||||
diff(object: NgIterable<V>): IterableChanges<V>|null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,20 +92,16 @@ export interface IterableChanges<V> {
|
|||
*/
|
||||
export interface IterableChangeRecord<V> {
|
||||
/** Current index of the item in `Iterable` or null if removed. */
|
||||
// TODO(TS2.1): make readonly once we move to TS v2.1
|
||||
/* readonly */ currentIndex: number;
|
||||
readonly currentIndex: number|null;
|
||||
|
||||
/** Previous index of the item in `Iterable` or null if added. */
|
||||
// TODO(TS2.1): make readonly once we move to TS v2.1
|
||||
/* readonly */ previousIndex: number;
|
||||
readonly previousIndex: number|null;
|
||||
|
||||
/** The item. */
|
||||
// TODO(TS2.1): make readonly once we move to TS v2.1
|
||||
/* readonly */ item: V;
|
||||
readonly item: V;
|
||||
|
||||
/** Track by identity as computed by the `trackByFn`. */
|
||||
// TODO(TS2.1): make readonly once we move to TS v2.1
|
||||
/* readonly */ trackById: any;
|
||||
readonly trackById: any;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -82,17 +82,17 @@ export interface KeyValueChangeRecord<K, V> {
|
|||
/**
|
||||
* Current key in the Map.
|
||||
*/
|
||||
/* readonly */ key: K;
|
||||
readonly key: K;
|
||||
|
||||
/**
|
||||
* Current value for the key or `undefined` if removed.
|
||||
* Current value for the key or `null` if removed.
|
||||
*/
|
||||
/* readonly */ currentValue: V;
|
||||
readonly currentValue: V|null;
|
||||
|
||||
/**
|
||||
* Previous value for the key or `undefined` if added.
|
||||
* Previous value for the key or `null` if added.
|
||||
*/
|
||||
/* readonly */ previousValue: V;
|
||||
readonly previousValue: V|null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,9 +17,9 @@ export class EventListener { constructor(public name: string, public callback: F
|
|||
export class DebugNode {
|
||||
nativeNode: any;
|
||||
listeners: EventListener[];
|
||||
parent: DebugElement;
|
||||
parent: DebugElement|null;
|
||||
|
||||
constructor(nativeNode: any, parent: DebugNode, private _debugContext: DebugContext) {
|
||||
constructor(nativeNode: any, parent: DebugNode|null, private _debugContext: DebugContext) {
|
||||
this.nativeNode = nativeNode;
|
||||
if (parent && parent instanceof DebugElement) {
|
||||
parent.addChild(this);
|
||||
|
@ -29,19 +29,15 @@ export class DebugNode {
|
|||
this.listeners = [];
|
||||
}
|
||||
|
||||
get injector(): Injector { return this._debugContext ? this._debugContext.injector : null; }
|
||||
get injector(): Injector { return this._debugContext.injector; }
|
||||
|
||||
get componentInstance(): any { return this._debugContext ? this._debugContext.component : null; }
|
||||
get componentInstance(): any { return this._debugContext.component; }
|
||||
|
||||
get context(): any { return this._debugContext ? this._debugContext.context : null; }
|
||||
get context(): any { return this._debugContext.context; }
|
||||
|
||||
get references(): {[key: string]: any} {
|
||||
return this._debugContext ? this._debugContext.references : null;
|
||||
}
|
||||
get references(): {[key: string]: any} { return this._debugContext.references; }
|
||||
|
||||
get providerTokens(): any[] {
|
||||
return this._debugContext ? this._debugContext.providerTokens : null;
|
||||
}
|
||||
get providerTokens(): any[] { return this._debugContext.providerTokens; }
|
||||
|
||||
/**
|
||||
* @deprecated since v4
|
||||
|
@ -55,9 +51,9 @@ export class DebugNode {
|
|||
export class DebugElement extends DebugNode {
|
||||
name: string;
|
||||
properties: {[key: string]: any};
|
||||
attributes: {[key: string]: string};
|
||||
attributes: {[key: string]: string | null};
|
||||
classes: {[key: string]: boolean};
|
||||
styles: {[key: string]: string};
|
||||
styles: {[key: string]: string | null};
|
||||
childNodes: DebugNode[];
|
||||
nativeElement: any;
|
||||
|
||||
|
@ -181,8 +177,8 @@ const _nativeNodeToDebugNode = new Map<any, DebugNode>();
|
|||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export function getDebugNode(nativeNode: any): DebugNode {
|
||||
return _nativeNodeToDebugNode.get(nativeNode);
|
||||
export function getDebugNode(nativeNode: any): DebugNode|null {
|
||||
return _nativeNodeToDebugNode.get(nativeNode) || null;
|
||||
}
|
||||
|
||||
export function getAllDebugNodes(): DebugNode[] {
|
||||
|
@ -203,4 +199,4 @@ export function removeDebugNodeFromIndex(node: DebugNode) {
|
|||
*
|
||||
* @experimental All debugging apis are currently experimental.
|
||||
*/
|
||||
export interface Predicate<T> { (value: T, index?: number, array?: T[]): boolean; }
|
||||
export interface Predicate<T> { (value: T): boolean; }
|
||||
|
|
|
@ -115,7 +115,7 @@ export abstract class ReflectiveInjector implements Injector {
|
|||
* because it needs to resolve the passed-in providers first.
|
||||
* See {@link Injector#resolve} and {@link Injector#fromResolvedProviders}.
|
||||
*/
|
||||
static resolveAndCreate(providers: Provider[], parent: Injector = null): ReflectiveInjector {
|
||||
static resolveAndCreate(providers: Provider[], parent?: Injector): ReflectiveInjector {
|
||||
const ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
||||
return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ export abstract class ReflectiveInjector implements Injector {
|
|||
* ```
|
||||
* @experimental
|
||||
*/
|
||||
static fromResolvedProviders(providers: ResolvedReflectiveProvider[], parent: Injector = null):
|
||||
static fromResolvedProviders(providers: ResolvedReflectiveProvider[], parent?: Injector):
|
||||
ReflectiveInjector {
|
||||
return new ReflectiveInjector_(providers, parent);
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ export abstract class ReflectiveInjector implements Injector {
|
|||
* expect(child.parent).toBe(parent);
|
||||
* ```
|
||||
*/
|
||||
abstract get parent(): Injector;
|
||||
abstract get parent(): Injector|null;
|
||||
|
||||
/**
|
||||
* Resolves an array of providers and creates a child injector from those providers.
|
||||
|
@ -282,16 +282,16 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
|||
/** @internal */
|
||||
public _providers: ResolvedReflectiveProvider[];
|
||||
/** @internal */
|
||||
public _parent: Injector;
|
||||
public _parent: Injector|null;
|
||||
|
||||
keyIds: number[];
|
||||
objs: any[];
|
||||
/**
|
||||
* Private
|
||||
*/
|
||||
constructor(_providers: ResolvedReflectiveProvider[], _parent: Injector = null) {
|
||||
constructor(_providers: ResolvedReflectiveProvider[], _parent?: Injector) {
|
||||
this._providers = _providers;
|
||||
this._parent = _parent;
|
||||
this._parent = _parent || null;
|
||||
|
||||
const len = _providers.length;
|
||||
|
||||
|
@ -308,7 +308,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
|||
return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
|
||||
}
|
||||
|
||||
get parent(): Injector { return this._parent; }
|
||||
get parent(): Injector|null { return this._parent; }
|
||||
|
||||
resolveAndCreateChild(providers: Provider[]): ReflectiveInjector {
|
||||
const ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
||||
|
@ -388,7 +388,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
|||
return this._getByKey(dep.key, dep.visibility, dep.optional ? null : THROW_IF_NOT_FOUND);
|
||||
}
|
||||
|
||||
private _getByKey(key: ReflectiveKey, visibility: Self|SkipSelf, notFoundValue: any): any {
|
||||
private _getByKey(key: ReflectiveKey, visibility: Self|SkipSelf|null, notFoundValue: any): any {
|
||||
if (key === INJECTOR_KEY) {
|
||||
return this;
|
||||
}
|
||||
|
@ -431,8 +431,8 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
|||
}
|
||||
|
||||
/** @internal */
|
||||
_getByKeyDefault(key: ReflectiveKey, notFoundValue: any, visibility: Self|SkipSelf): any {
|
||||
let inj: Injector;
|
||||
_getByKeyDefault(key: ReflectiveKey, notFoundValue: any, visibility: Self|SkipSelf|null): any {
|
||||
let inj: Injector|null;
|
||||
|
||||
if (visibility instanceof SkipSelf) {
|
||||
inj = this._parent;
|
||||
|
|
|
@ -64,7 +64,7 @@ export class KeyRegistry {
|
|||
if (token instanceof ReflectiveKey) return token;
|
||||
|
||||
if (this._allKeys.has(token)) {
|
||||
return this._allKeys.get(token);
|
||||
return this._allKeys.get(token) !;
|
||||
}
|
||||
|
||||
const newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
|
||||
|
|
|
@ -26,7 +26,7 @@ interface NormalizedProvider extends TypeProvider, ValueProvider, ClassProvider,
|
|||
*/
|
||||
export class ReflectiveDependency {
|
||||
constructor(
|
||||
public key: ReflectiveKey, public optional: boolean, public visibility: Self|SkipSelf) {}
|
||||
public key: ReflectiveKey, public optional: boolean, public visibility: Self|SkipSelf|null) {}
|
||||
|
||||
static fromKey(key: ReflectiveKey): ReflectiveDependency {
|
||||
return new ReflectiveDependency(key, false, null);
|
||||
|
@ -128,7 +128,8 @@ function resolveReflectiveFactory(provider: NormalizedProvider): ResolvedReflect
|
|||
*/
|
||||
function resolveReflectiveProvider(provider: NormalizedProvider): ResolvedReflectiveProvider {
|
||||
return new ResolvedReflectiveProvider_(
|
||||
ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi);
|
||||
ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)],
|
||||
provider.multi || false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,7 +199,7 @@ function _normalizeProviders(providers: Provider[], res: Provider[]): Provider[]
|
|||
}
|
||||
|
||||
export function constructDependencies(
|
||||
typeOrFunc: any, dependencies: any[]): ReflectiveDependency[] {
|
||||
typeOrFunc: any, dependencies?: any[]): ReflectiveDependency[] {
|
||||
if (!dependencies) {
|
||||
return _dependenciesFor(typeOrFunc);
|
||||
} else {
|
||||
|
@ -230,7 +231,7 @@ function _extractToken(
|
|||
}
|
||||
}
|
||||
|
||||
let visibility: Self|SkipSelf = null;
|
||||
let visibility: Self|SkipSelf|null = null;
|
||||
|
||||
for (let i = 0; i < metadata.length; ++i) {
|
||||
const paramMetadata = metadata[i];
|
||||
|
@ -261,6 +262,6 @@ function _extractToken(
|
|||
}
|
||||
|
||||
function _createDependency(
|
||||
token: any, optional: boolean, visibility: Self | SkipSelf): ReflectiveDependency {
|
||||
token: any, optional: boolean, visibility: Self | SkipSelf | null): ReflectiveDependency {
|
||||
return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ export class CodegenComponentFactoryResolver implements ComponentFactoryResolver
|
|||
resolveComponentFactory<T>(component: {new (...args: any[]): T}): ComponentFactory<T> {
|
||||
let factory = this._factories.get(component) || this._parent.resolveComponentFactory(component);
|
||||
|
||||
return factory ? new ComponentFactoryBoundToModule(factory, this._ngModule) : null;
|
||||
return new ComponentFactoryBoundToModule(factory, this._ngModule);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ export class NgModuleFactory<T> {
|
|||
|
||||
get moduleType(): Type<T> { return this._moduleType; }
|
||||
|
||||
create(parentInjector: Injector): NgModuleRef<T> {
|
||||
create(parentInjector: Injector|null): NgModuleRef<T> {
|
||||
const instance = new this._injectorClass(parentInjector || Injector.NULL);
|
||||
instance.create();
|
||||
return instance;
|
||||
|
|
|
@ -63,7 +63,9 @@ export class QueryList<T>/* implements Iterable<T> */ {
|
|||
* See
|
||||
* [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
|
||||
*/
|
||||
find(fn: (item: T, index: number, array: T[]) => boolean): T { return this._results.find(fn); }
|
||||
find(fn: (item: T, index: number, array: T[]) => boolean): T|undefined {
|
||||
return this._results.find(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* See
|
||||
|
|
|
@ -51,7 +51,7 @@ export abstract class ViewContainerRef {
|
|||
/**
|
||||
* Returns the {@link ViewRef} for the View located in this container at the specified index.
|
||||
*/
|
||||
abstract get(index: number): ViewRef;
|
||||
abstract get(index: number): ViewRef|null;
|
||||
|
||||
/**
|
||||
* Returns the number of Views currently attached to this container.
|
||||
|
@ -120,5 +120,5 @@ export abstract class ViewContainerRef {
|
|||
*
|
||||
* If the `index` param is omitted, the last {@link ViewRef} is detached.
|
||||
*/
|
||||
abstract detach(index?: number): ViewRef;
|
||||
abstract detach(index?: number): ViewRef|null;
|
||||
}
|
||||
|
|
|
@ -62,19 +62,19 @@ export enum ViewEncapsulation {
|
|||
*/
|
||||
export class ViewMetadata {
|
||||
/** {@link Component.templateUrl} */
|
||||
templateUrl: string;
|
||||
templateUrl: string|undefined;
|
||||
/** {@link Component.template} */
|
||||
template: string;
|
||||
template: string|undefined;
|
||||
/** {@link Component.stylesUrl} */
|
||||
styleUrls: string[];
|
||||
styleUrls: string[]|undefined;
|
||||
/** {@link Component.styles} */
|
||||
styles: string[];
|
||||
styles: string[]|undefined;
|
||||
/** {@link Component.encapsulation} */
|
||||
encapsulation: ViewEncapsulation;
|
||||
encapsulation: ViewEncapsulation|undefined;
|
||||
/** {@link Component.animation} */
|
||||
animations: any[];
|
||||
animations: any[]|undefined;
|
||||
/** {@link Component.interpolation} */
|
||||
interpolation: [string, string];
|
||||
interpolation: [string, string]|undefined;
|
||||
|
||||
constructor(
|
||||
{templateUrl, template, encapsulation, styles, styleUrls, animations, interpolation}: {
|
||||
|
|
|
@ -53,7 +53,9 @@ export function createScope(signature: string, flags: any = null): any {
|
|||
return events.createScope(signature, flags);
|
||||
}
|
||||
|
||||
export function leave<T>(scope: Scope, returnValue?: T): T {
|
||||
export function leave<T>(scope: Scope): void;
|
||||
export function leave<T>(scope: Scope, returnValue?: T): T;
|
||||
export function leave<T>(scope: Scope, returnValue?: any): any {
|
||||
trace.leaveScope(scope, returnValue);
|
||||
return returnValue;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@ export interface PlatformReflectionCapabilities {
|
|||
method(name: string): MethodFn;
|
||||
importUri(type: Type<any>): string;
|
||||
resourceUri(type: Type<any>): string;
|
||||
resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any;
|
||||
resolveIdentifier(name: string, moduleUrl: string, members: string[]|null, runtime: any): any;
|
||||
resolveEnum(enumIdentifier: any, name: string): any;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
|||
return result;
|
||||
}
|
||||
|
||||
private _ownParameters(type: Type<any>, parentCtor: any): any[][] {
|
||||
private _ownParameters(type: Type<any>, parentCtor: any): any[][]|null {
|
||||
// If we have no decorators, we only have function.length as metadata.
|
||||
// In that case, to detect whether a child class declared an own constructor or not,
|
||||
// we need to look inside of that constructor to check whether it is
|
||||
|
@ -115,7 +115,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
|||
return parameters || [];
|
||||
}
|
||||
|
||||
private _ownAnnotations(typeOrFunc: Type<any>, parentCtor: any): any[] {
|
||||
private _ownAnnotations(typeOrFunc: Type<any>, parentCtor: any): any[]|null {
|
||||
// Prefer the direct API.
|
||||
if ((<any>typeOrFunc).annotations && (<any>typeOrFunc).annotations !== parentCtor.annotations) {
|
||||
let annotations = (<any>typeOrFunc).annotations;
|
||||
|
@ -134,6 +134,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
|||
if (this._reflect && this._reflect.getOwnMetadata) {
|
||||
return this._reflect.getOwnMetadata('annotations', typeOrFunc);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
annotations(typeOrFunc: Type<any>): any[] {
|
||||
|
@ -146,7 +147,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
|||
return parentAnnotations.concat(ownAnnotations);
|
||||
}
|
||||
|
||||
private _ownPropMetadata(typeOrFunc: any, parentCtor: any): {[key: string]: any[]} {
|
||||
private _ownPropMetadata(typeOrFunc: any, parentCtor: any): {[key: string]: any[]}|null {
|
||||
// Prefer the direct API.
|
||||
if ((<any>typeOrFunc).propMetadata &&
|
||||
(<any>typeOrFunc).propMetadata !== parentCtor.propMetadata) {
|
||||
|
@ -172,6 +173,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
|||
if (this._reflect && this._reflect.getOwnMetadata) {
|
||||
return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
propMetadata(typeOrFunc: any): {[key: string]: any[]} {
|
||||
|
|
|
@ -51,7 +51,7 @@ export class Reflector extends ReflectorReader {
|
|||
|
||||
resourceUri(type: any): string { return this.reflectionCapabilities.resourceUri(type); }
|
||||
|
||||
resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any {
|
||||
resolveIdentifier(name: string, moduleUrl: string, members: string[]|null, runtime: any): any {
|
||||
return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ export abstract class ReflectorReader {
|
|||
abstract parameters(typeOrFunc: /*Type*/ any): any[][];
|
||||
abstract annotations(typeOrFunc: /*Type*/ any): any[];
|
||||
abstract propMetadata(typeOrFunc: /*Type*/ any): {[key: string]: any[]};
|
||||
abstract importUri(typeOrFunc: /*Type*/ any): string;
|
||||
abstract importUri(typeOrFunc: /*Type*/ any): string|null;
|
||||
abstract resourceUri(typeOrFunc: /*Type*/ any): string;
|
||||
abstract resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any;
|
||||
abstract resolveEnum(identifier: any, name: string): any;
|
||||
|
|
|
@ -126,7 +126,7 @@ export interface RendererType2 {
|
|||
* @experimental
|
||||
*/
|
||||
export abstract class RendererFactory2 {
|
||||
abstract createRenderer(hostElement: any, type: RendererType2): Renderer2;
|
||||
abstract createRenderer(hostElement: any, type: RendererType2|null): Renderer2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,7 +148,7 @@ export abstract class Renderer2 {
|
|||
abstract get data(): {[key: string]: any};
|
||||
|
||||
abstract destroy(): void;
|
||||
abstract createElement(name: string, namespace?: string): any;
|
||||
abstract createElement(name: string, namespace?: string|null): any;
|
||||
abstract createComment(value: string): any;
|
||||
abstract createText(value: string): any;
|
||||
/**
|
||||
|
@ -156,7 +156,7 @@ export abstract class Renderer2 {
|
|||
* in which case the view engine won't call it.
|
||||
* This is used as a performance optimization for production mode.
|
||||
*/
|
||||
destroyNode: (node: any) => void | null;
|
||||
destroyNode: ((node: any) => void)|null;
|
||||
abstract appendChild(parent: any, newChild: any): void;
|
||||
abstract insertBefore(parent: any, newChild: any, refChild: any): void;
|
||||
abstract removeChild(parent: any, oldChild: any): void;
|
||||
|
@ -173,8 +173,8 @@ export abstract class Renderer2 {
|
|||
* the caller can't rely on checking whether this is null or not.
|
||||
*/
|
||||
abstract nextSibling(node: any): any;
|
||||
abstract setAttribute(el: any, name: string, value: string, namespace?: string): void;
|
||||
abstract removeAttribute(el: any, name: string, namespace?: string): void;
|
||||
abstract setAttribute(el: any, name: string, value: string, namespace?: string|null): void;
|
||||
abstract removeAttribute(el: any, name: string, namespace?: string|null): void;
|
||||
abstract addClass(el: any, name: string): void;
|
||||
abstract removeClass(el: any, name: string): void;
|
||||
abstract setStyle(el: any, style: string, value: any, flags?: RendererStyleFlags2): void;
|
||||
|
|
|
@ -92,7 +92,7 @@ export class Testability implements PublicTestability {
|
|||
// Schedules the call backs in a new frame so that it is always async.
|
||||
scheduleMicroTask(() => {
|
||||
while (this._callbacks.length !== 0) {
|
||||
(this._callbacks.pop())(this._didWork);
|
||||
(this._callbacks.pop() !)(this._didWork);
|
||||
}
|
||||
this._didWork = false;
|
||||
});
|
||||
|
@ -136,13 +136,13 @@ export class TestabilityRegistry {
|
|||
this._applications.set(token, testability);
|
||||
}
|
||||
|
||||
getTestability(elem: any): Testability { return this._applications.get(elem); }
|
||||
getTestability(elem: any): Testability|null { return this._applications.get(elem) || null; }
|
||||
|
||||
getAllTestabilities(): Testability[] { return Array.from(this._applications.values()); }
|
||||
|
||||
getAllRootElements(): any[] { return Array.from(this._applications.keys()); }
|
||||
|
||||
findTestabilityInTree(elem: Node, findInAncestors: boolean = true): Testability {
|
||||
findTestabilityInTree(elem: Node, findInAncestors: boolean = true): Testability|null {
|
||||
return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
|
||||
}
|
||||
}
|
||||
|
@ -157,13 +157,13 @@ export class TestabilityRegistry {
|
|||
export interface GetTestability {
|
||||
addToWindow(registry: TestabilityRegistry): void;
|
||||
findTestabilityInTree(registry: TestabilityRegistry, elem: any, findInAncestors: boolean):
|
||||
Testability;
|
||||
Testability|null;
|
||||
}
|
||||
|
||||
class _NoopGetTestability implements GetTestability {
|
||||
addToWindow(registry: TestabilityRegistry): void {}
|
||||
findTestabilityInTree(registry: TestabilityRegistry, elem: any, findInAncestors: boolean):
|
||||
Testability {
|
||||
Testability|null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ function extractAnnotation(annotation: any): any {
|
|||
return annotation;
|
||||
}
|
||||
|
||||
function applyParams(fnOrArray: (Function | any[]), key: string): Function {
|
||||
function applyParams(fnOrArray: Function | any[] | undefined, key: string): Function {
|
||||
if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
|
||||
fnOrArray === Number || fnOrArray === Array) {
|
||||
throw new Error(`Can not use native ${stringify(fnOrArray)} as constructor`);
|
||||
|
@ -107,7 +107,7 @@ function applyParams(fnOrArray: (Function | any[]), key: string): Function {
|
|||
}
|
||||
|
||||
if (Array.isArray(fnOrArray)) {
|
||||
const annotations: any[] = fnOrArray;
|
||||
const annotations: any[] = fnOrArray as any[];
|
||||
const annoLength = annotations.length - 1;
|
||||
const fn: Function = fnOrArray[annoLength];
|
||||
if (typeof fn !== 'function') {
|
||||
|
@ -263,7 +263,7 @@ export function Class(clsDef: ClassDefinition): Type<any> {
|
|||
*/
|
||||
export function makeDecorator(
|
||||
name: string, props: {[name: string]: any}, parentClass?: any,
|
||||
chainFn: (fn: Function) => void = null): (...args: any[]) => (cls: any) => any {
|
||||
chainFn?: (fn: Function) => void): (...args: any[]) => (cls: any) => any {
|
||||
const metaCtor = makeMetadataCtor([props]);
|
||||
|
||||
function DecoratorFactory(objOrType: any): (cls: any) => any {
|
||||
|
@ -332,7 +332,7 @@ export function makeParamDecorator(
|
|||
return ParamDecorator;
|
||||
|
||||
function ParamDecorator(cls: any, unusedKey: any, index: number): any {
|
||||
const parameters: any[][] = Reflect.getOwnMetadata('parameters', cls) || [];
|
||||
const parameters: (any[] | null)[] = Reflect.getOwnMetadata('parameters', cls) || [];
|
||||
|
||||
// there might be gaps if some in between parameters do not have annotations.
|
||||
// we pad with nulls.
|
||||
|
@ -341,7 +341,7 @@ export function makeParamDecorator(
|
|||
}
|
||||
|
||||
parameters[index] = parameters[index] || [];
|
||||
parameters[index].push(annotationInstance);
|
||||
parameters[index] !.push(annotationInstance);
|
||||
|
||||
Reflect.defineMetadata('parameters', parameters, cls);
|
||||
return cls;
|
||||
|
|
|
@ -16,20 +16,17 @@ export function anchorDef(
|
|||
flags: NodeFlags, matchedQueriesDsl: [string | number, QueryValueType][],
|
||||
ngContentIndex: number, childCount: number, handleEvent?: ElementHandleEventFn,
|
||||
templateFactory?: ViewDefinitionFactory): NodeDef {
|
||||
if (!handleEvent) {
|
||||
handleEvent = NOOP;
|
||||
}
|
||||
flags |= NodeFlags.TypeElement;
|
||||
const {matchedQueries, references, matchedQueryIds} = splitMatchedQueriesDsl(matchedQueriesDsl);
|
||||
const template = templateFactory ? resolveViewDefinition(templateFactory) : null;
|
||||
|
||||
return {
|
||||
// will bet set by the view definition
|
||||
index: undefined,
|
||||
parent: undefined,
|
||||
renderParent: undefined,
|
||||
bindingIndex: undefined,
|
||||
outputIndex: undefined,
|
||||
index: -1,
|
||||
parent: null,
|
||||
renderParent: null,
|
||||
bindingIndex: -1,
|
||||
outputIndex: -1,
|
||||
// regular values
|
||||
flags,
|
||||
childFlags: 0,
|
||||
|
@ -39,19 +36,20 @@ export function anchorDef(
|
|||
bindingFlags: 0,
|
||||
outputs: [],
|
||||
element: {
|
||||
ns: undefined,
|
||||
name: undefined,
|
||||
attrs: undefined, template,
|
||||
componentProvider: undefined,
|
||||
componentView: undefined,
|
||||
componentRendererType: undefined,
|
||||
publicProviders: undefined,
|
||||
allProviders: undefined, handleEvent
|
||||
ns: null,
|
||||
name: null,
|
||||
attrs: null, template,
|
||||
componentProvider: null,
|
||||
componentView: null,
|
||||
componentRendererType: null,
|
||||
publicProviders: null,
|
||||
allProviders: null,
|
||||
handleEvent: handleEvent || NOOP
|
||||
},
|
||||
provider: undefined,
|
||||
text: undefined,
|
||||
query: undefined,
|
||||
ngContent: undefined
|
||||
provider: null,
|
||||
text: null,
|
||||
query: null,
|
||||
ngContent: null
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -61,13 +59,13 @@ export function elementDef(
|
|||
fixedAttrs: [string, string][] = [],
|
||||
bindings?: [BindingFlags, string, string | SecurityContext][], outputs?: ([string, string])[],
|
||||
handleEvent?: ElementHandleEventFn, componentView?: ViewDefinitionFactory,
|
||||
componentRendererType?: RendererType2): NodeDef {
|
||||
componentRendererType?: RendererType2 | null): NodeDef {
|
||||
if (!handleEvent) {
|
||||
handleEvent = NOOP;
|
||||
}
|
||||
const {matchedQueries, references, matchedQueryIds} = splitMatchedQueriesDsl(matchedQueriesDsl);
|
||||
let ns: string;
|
||||
let name: string;
|
||||
let ns: string = null !;
|
||||
let name: string = null !;
|
||||
if (namespaceAndName) {
|
||||
[ns, name] = splitNamespace(namespaceAndName);
|
||||
}
|
||||
|
@ -77,8 +75,8 @@ export function elementDef(
|
|||
const [bindingFlags, namespaceAndName, suffixOrSecurityContext] = bindings[i];
|
||||
|
||||
const [ns, name] = splitNamespace(namespaceAndName);
|
||||
let securityContext: SecurityContext;
|
||||
let suffix: string;
|
||||
let securityContext: SecurityContext = undefined !;
|
||||
let suffix: string = undefined !;
|
||||
switch (bindingFlags & BindingFlags.Types) {
|
||||
case BindingFlags.TypeElementStyle:
|
||||
suffix = <string>suffixOrSecurityContext;
|
||||
|
@ -98,7 +96,7 @@ export function elementDef(
|
|||
outputDefs[i] = {
|
||||
type: OutputType.ElementOutput,
|
||||
target: <any>target, eventName,
|
||||
propName: undefined
|
||||
propName: null
|
||||
};
|
||||
}
|
||||
fixedAttrs = fixedAttrs || [];
|
||||
|
@ -113,11 +111,11 @@ export function elementDef(
|
|||
flags |= NodeFlags.TypeElement;
|
||||
return {
|
||||
// will bet set by the view definition
|
||||
index: undefined,
|
||||
parent: undefined,
|
||||
renderParent: undefined,
|
||||
bindingIndex: undefined,
|
||||
outputIndex: undefined,
|
||||
index: -1,
|
||||
parent: null,
|
||||
renderParent: null,
|
||||
bindingIndex: -1,
|
||||
outputIndex: -1,
|
||||
// regular values
|
||||
flags,
|
||||
childFlags: 0,
|
||||
|
@ -130,21 +128,24 @@ export function elementDef(
|
|||
ns,
|
||||
name,
|
||||
attrs,
|
||||
template: undefined,
|
||||
template: null,
|
||||
// will bet set by the view definition
|
||||
componentProvider: undefined, componentView, componentRendererType,
|
||||
publicProviders: undefined,
|
||||
allProviders: undefined, handleEvent,
|
||||
componentProvider: null,
|
||||
componentView: componentView || null,
|
||||
componentRendererType: componentRendererType,
|
||||
publicProviders: null,
|
||||
allProviders: null,
|
||||
handleEvent: handleEvent || NOOP,
|
||||
},
|
||||
provider: undefined,
|
||||
text: undefined,
|
||||
query: undefined,
|
||||
ngContent: undefined
|
||||
provider: null,
|
||||
text: null,
|
||||
query: null,
|
||||
ngContent: null
|
||||
};
|
||||
}
|
||||
|
||||
export function createElement(view: ViewData, renderHost: any, def: NodeDef): ElementData {
|
||||
const elDef = def.element;
|
||||
const elDef = def.element !;
|
||||
const rootSelectorOrNode = view.root.selectorOrNode;
|
||||
const renderer = view.renderer;
|
||||
let el: any;
|
||||
|
@ -175,7 +176,7 @@ export function listenToElementOutputs(view: ViewData, compView: ViewData, def:
|
|||
const output = def.outputs[i];
|
||||
const handleEventClosure = renderEventHandlerClosure(
|
||||
view, def.index, elementEventFullName(output.target, output.eventName));
|
||||
let listenTarget = output.target;
|
||||
let listenTarget: 'window'|'document'|'body'|'component'|null = output.target;
|
||||
let listenerView = view;
|
||||
if (output.target === 'component') {
|
||||
listenTarget = null;
|
||||
|
@ -183,7 +184,7 @@ export function listenToElementOutputs(view: ViewData, compView: ViewData, def:
|
|||
}
|
||||
const disposable =
|
||||
<any>listenerView.renderer.listen(listenTarget || el, output.eventName, handleEventClosure);
|
||||
view.disposables[def.outputIndex + i] = disposable;
|
||||
view.disposables ![def.outputIndex + i] = disposable;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +226,7 @@ function checkAndUpdateElementValue(view: ViewData, def: NodeDef, bindingIdx: nu
|
|||
const binding = def.bindings[bindingIdx];
|
||||
const elData = asElementData(view, def.index);
|
||||
const renderNode = elData.renderElement;
|
||||
const name = binding.name;
|
||||
const name = binding.name !;
|
||||
switch (binding.flags & BindingFlags.Types) {
|
||||
case BindingFlags.TypeElementAttribute:
|
||||
setElementAttribute(view, binding, renderNode, binding.ns, name, value);
|
||||
|
@ -248,7 +249,8 @@ function checkAndUpdateElementValue(view: ViewData, def: NodeDef, bindingIdx: nu
|
|||
}
|
||||
|
||||
function setElementAttribute(
|
||||
view: ViewData, binding: BindingDef, renderNode: any, ns: string, name: string, value: any) {
|
||||
view: ViewData, binding: BindingDef, renderNode: any, ns: string | null, name: string,
|
||||
value: any) {
|
||||
const securityContext = binding.securityContext;
|
||||
let renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
|
||||
renderValue = renderValue != null ? renderValue.toString() : null;
|
||||
|
@ -271,7 +273,7 @@ function setElementClass(view: ViewData, renderNode: any, name: string, value: b
|
|||
|
||||
function setElementStyle(
|
||||
view: ViewData, binding: BindingDef, renderNode: any, name: string, value: any) {
|
||||
let renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, value);
|
||||
let renderValue: string|null = view.root.sanitizer.sanitize(SecurityContext.STYLE, value);
|
||||
if (renderValue != null) {
|
||||
renderValue = renderValue.toString();
|
||||
const unit = binding.suffix;
|
||||
|
|
|
@ -12,11 +12,11 @@ import {RenderNodeAction, getParentRenderElement, visitProjectedRenderNodes} fro
|
|||
export function ngContentDef(ngContentIndex: number, index: number): NodeDef {
|
||||
return {
|
||||
// will bet set by the view definition
|
||||
index: undefined,
|
||||
parent: undefined,
|
||||
renderParent: undefined,
|
||||
bindingIndex: undefined,
|
||||
outputIndex: undefined,
|
||||
index: -1,
|
||||
parent: null,
|
||||
renderParent: null,
|
||||
bindingIndex: -1,
|
||||
outputIndex: -1,
|
||||
// regular values
|
||||
flags: NodeFlags.TypeNgContent,
|
||||
childFlags: 0,
|
||||
|
@ -29,10 +29,10 @@ export function ngContentDef(ngContentIndex: number, index: number): NodeDef {
|
|||
bindings: [],
|
||||
bindingFlags: 0,
|
||||
outputs: [],
|
||||
element: undefined,
|
||||
provider: undefined,
|
||||
text: undefined,
|
||||
query: undefined,
|
||||
element: null,
|
||||
provider: null,
|
||||
text: null,
|
||||
query: null,
|
||||
ngContent: {index}
|
||||
};
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ export function appendNgContent(view: ViewData, renderHost: any, def: NodeDef) {
|
|||
// Nothing to do if there is no parent element.
|
||||
return;
|
||||
}
|
||||
const ngContentIndex = def.ngContent.index;
|
||||
const ngContentIndex = def.ngContent !.index;
|
||||
visitProjectedRenderNodes(
|
||||
view, ngContentIndex, RenderNodeAction.AppendChild, parentEl, undefined, undefined);
|
||||
view, ngContentIndex, RenderNodeAction.AppendChild, parentEl, null, undefined);
|
||||
}
|
||||
|
|
|
@ -38,9 +38,9 @@ export function directiveDef(
|
|||
bindings[bindingIndex] = {
|
||||
flags: BindingFlags.TypeProperty,
|
||||
name: prop, nonMinifiedName,
|
||||
ns: undefined,
|
||||
securityContext: undefined,
|
||||
suffix: undefined
|
||||
ns: null,
|
||||
securityContext: null,
|
||||
suffix: null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -67,9 +67,9 @@ export function providerDef(
|
|||
}
|
||||
|
||||
export function _def(
|
||||
flags: NodeFlags, matchedQueriesDsl: [string | number, QueryValueType][], childCount: number,
|
||||
token: any, value: any, deps: ([DepFlags, any] | any)[], bindings?: BindingDef[],
|
||||
outputs?: OutputDef[]): NodeDef {
|
||||
flags: NodeFlags, matchedQueriesDsl: [string | number, QueryValueType][] | null,
|
||||
childCount: number, token: any, value: any, deps: ([DepFlags, any] | any)[],
|
||||
bindings?: BindingDef[], outputs?: OutputDef[]): NodeDef {
|
||||
const {matchedQueries, references, matchedQueryIds} = splitMatchedQueriesDsl(matchedQueriesDsl);
|
||||
if (!outputs) {
|
||||
outputs = [];
|
||||
|
@ -92,23 +92,23 @@ export function _def(
|
|||
|
||||
return {
|
||||
// will bet set by the view definition
|
||||
index: undefined,
|
||||
parent: undefined,
|
||||
renderParent: undefined,
|
||||
bindingIndex: undefined,
|
||||
outputIndex: undefined,
|
||||
index: -1,
|
||||
parent: null,
|
||||
renderParent: null,
|
||||
bindingIndex: -1,
|
||||
outputIndex: -1,
|
||||
// regular values
|
||||
flags,
|
||||
childFlags: 0,
|
||||
directChildFlags: 0,
|
||||
childMatchedQueries: 0, matchedQueries, matchedQueryIds, references,
|
||||
ngContentIndex: undefined, childCount, bindings,
|
||||
ngContentIndex: -1, childCount, bindings,
|
||||
bindingFlags: calcBindingFlags(bindings), outputs,
|
||||
element: undefined,
|
||||
element: null,
|
||||
provider: {token, tokenKey: tokenKey(token), value, deps: depDefs},
|
||||
text: undefined,
|
||||
query: undefined,
|
||||
ngContent: undefined
|
||||
text: null,
|
||||
query: null,
|
||||
ngContent: null
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -126,22 +126,22 @@ export function createPipeInstance(view: ViewData, def: NodeDef): any {
|
|||
const allowPrivateServices = true;
|
||||
// pipes are always eager and classes!
|
||||
return createClass(
|
||||
compView.parent, viewParentEl(compView), allowPrivateServices, def.provider.value,
|
||||
def.provider.deps);
|
||||
compView.parent !, viewParentEl(compView) !, allowPrivateServices, def.provider !.value,
|
||||
def.provider !.deps);
|
||||
}
|
||||
|
||||
export function createDirectiveInstance(view: ViewData, def: NodeDef): any {
|
||||
// components can see other private services, other directives can't.
|
||||
const allowPrivateServices = (def.flags & NodeFlags.Component) > 0;
|
||||
// directives are always eager and classes!
|
||||
const instance =
|
||||
createClass(view, def.parent, allowPrivateServices, def.provider.value, def.provider.deps);
|
||||
const instance = createClass(
|
||||
view, def.parent !, allowPrivateServices, def.provider !.value, def.provider !.deps);
|
||||
if (def.outputs.length) {
|
||||
for (let i = 0; i < def.outputs.length; i++) {
|
||||
const output = def.outputs[i];
|
||||
const subscription = instance[output.propName].subscribe(
|
||||
eventHandlerClosure(view, def.parent.index, output.eventName));
|
||||
view.disposables[def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
|
||||
const subscription = instance[output.propName !].subscribe(
|
||||
eventHandlerClosure(view, def.parent !.index, output.eventName));
|
||||
view.disposables ![def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
|
@ -157,7 +157,7 @@ export function checkAndUpdateDirectiveInline(
|
|||
const providerData = asProviderData(view, def.index);
|
||||
const directive = providerData.instance;
|
||||
let changed = false;
|
||||
let changes: SimpleChanges;
|
||||
let changes: SimpleChanges = undefined !;
|
||||
const bindLen = def.bindings.length;
|
||||
if (bindLen > 0 && checkBinding(view, def, 0, v0)) {
|
||||
changed = true;
|
||||
|
@ -216,7 +216,7 @@ export function checkAndUpdateDirectiveDynamic(
|
|||
const providerData = asProviderData(view, def.index);
|
||||
const directive = providerData.instance;
|
||||
let changed = false;
|
||||
let changes: SimpleChanges;
|
||||
let changes: SimpleChanges = undefined !;
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
if (checkBinding(view, def, i, values[i])) {
|
||||
changed = true;
|
||||
|
@ -242,18 +242,18 @@ function _createProviderInstance(view: ViewData, def: NodeDef): any {
|
|||
let injectable: any;
|
||||
switch (def.flags & NodeFlags.Types) {
|
||||
case NodeFlags.TypeClassProvider:
|
||||
injectable =
|
||||
createClass(view, def.parent, allowPrivateServices, providerDef.value, providerDef.deps);
|
||||
injectable = createClass(
|
||||
view, def.parent !, allowPrivateServices, providerDef !.value, providerDef !.deps);
|
||||
break;
|
||||
case NodeFlags.TypeFactoryProvider:
|
||||
injectable =
|
||||
callFactory(view, def.parent, allowPrivateServices, providerDef.value, providerDef.deps);
|
||||
injectable = callFactory(
|
||||
view, def.parent !, allowPrivateServices, providerDef !.value, providerDef !.deps);
|
||||
break;
|
||||
case NodeFlags.TypeUseExistingProvider:
|
||||
injectable = resolveDep(view, def.parent, allowPrivateServices, providerDef.deps[0]);
|
||||
injectable = resolveDep(view, def.parent !, allowPrivateServices, providerDef !.deps[0]);
|
||||
break;
|
||||
case NodeFlags.TypeValueProvider:
|
||||
injectable = providerDef.value;
|
||||
injectable = providerDef !.value;
|
||||
break;
|
||||
}
|
||||
return injectable;
|
||||
|
@ -345,7 +345,7 @@ export const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
|
|||
|
||||
export function resolveDep(
|
||||
view: ViewData, elDef: NodeDef, allowPrivateServices: boolean, depDef: DepDef,
|
||||
notFoundValue = Injector.THROW_IF_NOT_FOUND): any {
|
||||
notFoundValue: any = Injector.THROW_IF_NOT_FOUND): any {
|
||||
if (depDef.flags & DepFlags.Value) {
|
||||
return depDef.token;
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ export function resolveDep(
|
|||
|
||||
if (elDef && (depDef.flags & DepFlags.SkipSelf)) {
|
||||
allowPrivateServices = false;
|
||||
elDef = elDef.parent;
|
||||
elDef = elDef.parent !;
|
||||
}
|
||||
|
||||
while (view) {
|
||||
|
@ -376,7 +376,7 @@ export function resolveDep(
|
|||
case ViewContainerRefTokenKey:
|
||||
return asElementData(view, elDef.index).viewContainer;
|
||||
case TemplateRefTokenKey: {
|
||||
if (elDef.element.template) {
|
||||
if (elDef.element !.template) {
|
||||
return asElementData(view, elDef.index).template;
|
||||
}
|
||||
break;
|
||||
|
@ -389,8 +389,8 @@ export function resolveDep(
|
|||
return createInjector(view, elDef);
|
||||
default:
|
||||
const providerDef =
|
||||
(allowPrivateServices ? elDef.element.allProviders :
|
||||
elDef.element.publicProviders)[tokenKey];
|
||||
(allowPrivateServices ? elDef.element !.allProviders :
|
||||
elDef.element !.publicProviders) ![tokenKey];
|
||||
if (providerDef) {
|
||||
const providerData = asProviderData(view, providerDef.index);
|
||||
if (providerData.instance === NOT_CREATED) {
|
||||
|
@ -401,8 +401,8 @@ export function resolveDep(
|
|||
}
|
||||
}
|
||||
allowPrivateServices = isComponentView(view);
|
||||
elDef = viewParentEl(view);
|
||||
view = view.parent;
|
||||
elDef = viewParentEl(view) !;
|
||||
view = view.parent !;
|
||||
}
|
||||
|
||||
const value = startView.root.injector.get(depDef.token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR);
|
||||
|
@ -437,13 +437,13 @@ function updateProp(
|
|||
view: ViewData, providerData: ProviderData, def: NodeDef, bindingIdx: number, value: any,
|
||||
changes: SimpleChanges): SimpleChanges {
|
||||
if (def.flags & NodeFlags.Component) {
|
||||
const compView = asElementData(view, def.parent.index).componentView;
|
||||
const compView = asElementData(view, def.parent !.index).componentView;
|
||||
if (compView.def.flags & ViewFlags.OnPush) {
|
||||
compView.state |= ViewState.ChecksEnabled;
|
||||
}
|
||||
}
|
||||
const binding = def.bindings[bindingIdx];
|
||||
const propName = binding.name;
|
||||
const propName = binding.name !;
|
||||
// Note: This is still safe with Closure Compiler as
|
||||
// the user passed in the property name as an object has to `providerDef`,
|
||||
// so Closure Compiler will have renamed the property correctly already.
|
||||
|
@ -455,7 +455,7 @@ function updateProp(
|
|||
oldValue = oldValue.wrapped;
|
||||
}
|
||||
const binding = def.bindings[bindingIdx];
|
||||
changes[binding.nonMinifiedName] =
|
||||
changes[binding.nonMinifiedName !] =
|
||||
new SimpleChange(oldValue, value, (view.state & ViewState.FirstCheck) !== 0);
|
||||
}
|
||||
view.oldValues[def.bindingIndex + bindingIdx] = value;
|
||||
|
|
|
@ -29,19 +29,19 @@ function _pureExpressionDef(flags: NodeFlags, propertyNames: string[]): NodeDef
|
|||
bindings[i] = {
|
||||
flags: BindingFlags.TypeProperty,
|
||||
name: prop,
|
||||
ns: undefined,
|
||||
ns: null,
|
||||
nonMinifiedName: prop,
|
||||
securityContext: undefined,
|
||||
suffix: undefined
|
||||
securityContext: null,
|
||||
suffix: null
|
||||
};
|
||||
}
|
||||
return {
|
||||
// will bet set by the view definition
|
||||
index: undefined,
|
||||
parent: undefined,
|
||||
renderParent: undefined,
|
||||
bindingIndex: undefined,
|
||||
outputIndex: undefined,
|
||||
index: -1,
|
||||
parent: null,
|
||||
renderParent: null,
|
||||
bindingIndex: -1,
|
||||
outputIndex: -1,
|
||||
// regular values
|
||||
flags,
|
||||
childFlags: 0,
|
||||
|
@ -50,15 +50,15 @@ function _pureExpressionDef(flags: NodeFlags, propertyNames: string[]): NodeDef
|
|||
matchedQueries: {},
|
||||
matchedQueryIds: 0,
|
||||
references: {},
|
||||
ngContentIndex: undefined,
|
||||
ngContentIndex: -1,
|
||||
childCount: 0, bindings,
|
||||
bindingFlags: calcBindingFlags(bindings),
|
||||
outputs: [],
|
||||
element: undefined,
|
||||
provider: undefined,
|
||||
text: undefined,
|
||||
query: undefined,
|
||||
ngContent: undefined
|
||||
element: null,
|
||||
provider: null,
|
||||
text: null,
|
||||
query: null,
|
||||
ngContent: null
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -102,16 +102,16 @@ export function checkAndUpdatePureExpressionInline(
|
|||
break;
|
||||
case NodeFlags.TypePureObject:
|
||||
value = {};
|
||||
if (bindLen > 0) value[bindings[0].name] = v0;
|
||||
if (bindLen > 1) value[bindings[1].name] = v1;
|
||||
if (bindLen > 2) value[bindings[2].name] = v2;
|
||||
if (bindLen > 3) value[bindings[3].name] = v3;
|
||||
if (bindLen > 4) value[bindings[4].name] = v4;
|
||||
if (bindLen > 5) value[bindings[5].name] = v5;
|
||||
if (bindLen > 6) value[bindings[6].name] = v6;
|
||||
if (bindLen > 7) value[bindings[7].name] = v7;
|
||||
if (bindLen > 8) value[bindings[8].name] = v8;
|
||||
if (bindLen > 9) value[bindings[9].name] = v9;
|
||||
if (bindLen > 0) value[bindings[0].name !] = v0;
|
||||
if (bindLen > 1) value[bindings[1].name !] = v1;
|
||||
if (bindLen > 2) value[bindings[2].name !] = v2;
|
||||
if (bindLen > 3) value[bindings[3].name !] = v3;
|
||||
if (bindLen > 4) value[bindings[4].name !] = v4;
|
||||
if (bindLen > 5) value[bindings[5].name !] = v5;
|
||||
if (bindLen > 6) value[bindings[6].name !] = v6;
|
||||
if (bindLen > 7) value[bindings[7].name !] = v7;
|
||||
if (bindLen > 8) value[bindings[8].name !] = v8;
|
||||
if (bindLen > 9) value[bindings[9].name !] = v9;
|
||||
break;
|
||||
case NodeFlags.TypePurePipe:
|
||||
const pipe = v0;
|
||||
|
@ -175,7 +175,7 @@ export function checkAndUpdatePureExpressionDynamic(
|
|||
case NodeFlags.TypePureObject:
|
||||
value = {};
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
value[bindings[i].name] = values[i];
|
||||
value[bindings[i].name !] = values[i];
|
||||
}
|
||||
break;
|
||||
case NodeFlags.TypePurePipe:
|
||||
|
|
|
@ -22,17 +22,17 @@ export function queryDef(
|
|||
|
||||
return {
|
||||
// will bet set by the view definition
|
||||
index: undefined,
|
||||
parent: undefined,
|
||||
renderParent: undefined,
|
||||
bindingIndex: undefined,
|
||||
outputIndex: undefined,
|
||||
index: -1,
|
||||
parent: null,
|
||||
renderParent: null,
|
||||
bindingIndex: -1,
|
||||
outputIndex: -1,
|
||||
// regular values
|
||||
flags,
|
||||
childFlags: 0,
|
||||
directChildFlags: 0,
|
||||
childMatchedQueries: 0,
|
||||
ngContentIndex: undefined,
|
||||
ngContentIndex: -1,
|
||||
matchedQueries: {},
|
||||
matchedQueryIds: 0,
|
||||
references: {},
|
||||
|
@ -40,11 +40,11 @@ export function queryDef(
|
|||
bindings: [],
|
||||
bindingFlags: 0,
|
||||
outputs: [],
|
||||
element: undefined,
|
||||
provider: undefined,
|
||||
text: undefined,
|
||||
element: null,
|
||||
provider: null,
|
||||
text: null,
|
||||
query: {id, filterId: filterQueryId(id), bindings: bindingDefs},
|
||||
ngContent: undefined
|
||||
ngContent: null
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ export function createQuery(): QueryList<any> {
|
|||
export function dirtyParentQueries(view: ViewData) {
|
||||
const queryIds = view.def.nodeMatchedQueries;
|
||||
while (view.parent && isEmbeddedView(view)) {
|
||||
let tplDef = view.parentNodeDef;
|
||||
let tplDef = view.parentNodeDef !;
|
||||
view = view.parent;
|
||||
// content queries
|
||||
const end = tplDef.index + tplDef.childCount;
|
||||
|
@ -63,7 +63,7 @@ export function dirtyParentQueries(view: ViewData) {
|
|||
const nodeDef = view.def.nodes[i];
|
||||
if ((nodeDef.flags & NodeFlags.TypeContentQuery) &&
|
||||
(nodeDef.flags & NodeFlags.DynamicQuery) &&
|
||||
(nodeDef.query.filterId & queryIds) === nodeDef.query.filterId) {
|
||||
(nodeDef.query !.filterId & queryIds) === nodeDef.query !.filterId) {
|
||||
asQueryList(view, i).setDirty();
|
||||
}
|
||||
if ((nodeDef.flags & NodeFlags.TypeElement && i + nodeDef.childCount < tplDef.index) ||
|
||||
|
@ -94,18 +94,18 @@ export function checkAndUpdateQuery(view: ViewData, nodeDef: NodeDef) {
|
|||
return;
|
||||
}
|
||||
let directiveInstance: any;
|
||||
let newValues: any[];
|
||||
let newValues: any[] = undefined !;
|
||||
if (nodeDef.flags & NodeFlags.TypeContentQuery) {
|
||||
const elementDef = nodeDef.parent.parent;
|
||||
const elementDef = nodeDef.parent !.parent !;
|
||||
newValues = calcQueryValues(
|
||||
view, elementDef.index, elementDef.index + elementDef.childCount, nodeDef.query, []);
|
||||
directiveInstance = asProviderData(view, nodeDef.parent.index).instance;
|
||||
view, elementDef.index, elementDef.index + elementDef.childCount, nodeDef.query !, []);
|
||||
directiveInstance = asProviderData(view, nodeDef.parent !.index).instance;
|
||||
} else if (nodeDef.flags & NodeFlags.TypeViewQuery) {
|
||||
newValues = calcQueryValues(view, 0, view.def.nodes.length - 1, nodeDef.query, []);
|
||||
newValues = calcQueryValues(view, 0, view.def.nodes.length - 1, nodeDef.query !, []);
|
||||
directiveInstance = view.component;
|
||||
}
|
||||
queryList.reset(newValues);
|
||||
const bindings = nodeDef.query.bindings;
|
||||
const bindings = nodeDef.query !.bindings;
|
||||
let notify = false;
|
||||
for (let i = 0; i < bindings.length; i++) {
|
||||
const binding = bindings[i];
|
||||
|
@ -135,12 +135,13 @@ function calcQueryValues(
|
|||
if (valueType != null) {
|
||||
values.push(getQueryValue(view, nodeDef, valueType));
|
||||
}
|
||||
if (nodeDef.flags & NodeFlags.TypeElement && nodeDef.element.template &&
|
||||
(nodeDef.element.template.nodeMatchedQueries & queryDef.filterId) === queryDef.filterId) {
|
||||
if (nodeDef.flags & NodeFlags.TypeElement && nodeDef.element !.template &&
|
||||
(nodeDef.element !.template !.nodeMatchedQueries & queryDef.filterId) ===
|
||||
queryDef.filterId) {
|
||||
// check embedded views that were attached at the place of their template.
|
||||
const elementData = asElementData(view, i);
|
||||
if (nodeDef.flags & NodeFlags.EmbeddedViews) {
|
||||
const embeddedViews = elementData.viewContainer._embeddedViews;
|
||||
const embeddedViews = elementData.viewContainer !._embeddedViews;
|
||||
for (let k = 0; k < embeddedViews.length; k++) {
|
||||
const embeddedView = embeddedViews[k];
|
||||
const dvc = declaredViewContainer(embeddedView);
|
||||
|
|
|
@ -85,7 +85,7 @@ class ComponentFactory_ extends ComponentFactory<any> {
|
|||
throw new Error('ngModule should be provided');
|
||||
}
|
||||
const viewDef = resolveViewDefinition(this.viewDefFactory);
|
||||
const componentNodeIndex = viewDef.nodes[0].element.componentProvider.index;
|
||||
const componentNodeIndex = viewDef.nodes[0].element !.componentProvider !.index;
|
||||
const view = Services.createRootView(
|
||||
injector, projectableNodes || [], rootSelectorOrNode, viewDef, ngModule, EMPTY_CONTEXT);
|
||||
const component = asProviderData(view, componentNodeIndex).instance;
|
||||
|
@ -135,7 +135,7 @@ class ViewContainerRef_ implements ViewContainerData {
|
|||
let elDef = this._elDef.parent;
|
||||
while (!elDef && view) {
|
||||
elDef = viewParentEl(view);
|
||||
view = view.parent;
|
||||
view = view.parent !;
|
||||
}
|
||||
|
||||
return view ? new Injector_(view, elDef) : new Injector_(this._view, null);
|
||||
|
@ -144,12 +144,12 @@ class ViewContainerRef_ implements ViewContainerData {
|
|||
clear(): void {
|
||||
const len = this._embeddedViews.length;
|
||||
for (let i = len - 1; i >= 0; i--) {
|
||||
const view = detachEmbeddedView(this._data, i);
|
||||
const view = detachEmbeddedView(this._data, i) !;
|
||||
Services.destroyView(view);
|
||||
}
|
||||
}
|
||||
|
||||
get(index: number): ViewRef {
|
||||
get(index: number): ViewRef|null {
|
||||
const view = this._embeddedViews[index];
|
||||
if (view) {
|
||||
const ref = new ViewRef_(view);
|
||||
|
@ -206,7 +206,7 @@ class ViewContainerRef_ implements ViewContainerData {
|
|||
}
|
||||
}
|
||||
|
||||
detach(index?: number): ViewRef {
|
||||
detach(index?: number): ViewRef|null {
|
||||
const view = detachEmbeddedView(this._data, index);
|
||||
return view ? new ViewRef_(view) : null;
|
||||
}
|
||||
|
@ -219,8 +219,8 @@ export function createChangeDetectorRef(view: ViewData): ChangeDetectorRef {
|
|||
export class ViewRef_ implements EmbeddedViewRef<any>, InternalViewRef {
|
||||
/** @internal */
|
||||
_view: ViewData;
|
||||
private _viewContainerRef: ViewContainerRef;
|
||||
private _appRef: ApplicationRef;
|
||||
private _viewContainerRef: ViewContainerRef|null;
|
||||
private _appRef: ApplicationRef|null;
|
||||
|
||||
constructor(_view: ViewData) {
|
||||
this._view = _view;
|
||||
|
@ -317,7 +317,7 @@ export function nodeValue(view: ViewData, index: number): any {
|
|||
const def = view.def.nodes[index];
|
||||
if (def.flags & NodeFlags.TypeElement) {
|
||||
const elData = asElementData(view, def.index);
|
||||
return def.element.template ? elData.template : elData.renderElement;
|
||||
return def.element !.template ? elData.template : elData.renderElement;
|
||||
} else if (def.flags & NodeFlags.TypeText) {
|
||||
return asTextData(view, def.index).renderText;
|
||||
} else if (def.flags & (NodeFlags.CatProvider | NodeFlags.TypePipe)) {
|
||||
|
@ -387,7 +387,7 @@ class RendererAdapter implements RendererV1 {
|
|||
|
||||
destroyView(hostElement: Element|DocumentFragment, viewAllNodes: Node[]) {
|
||||
for (let i = 0; i < viewAllNodes.length; i++) {
|
||||
this.delegate.destroyNode(viewAllNodes[i]);
|
||||
this.delegate.destroyNode !(viewAllNodes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,9 +159,9 @@ enum DebugAction {
|
|||
|
||||
let _currentAction: DebugAction;
|
||||
let _currentView: ViewData;
|
||||
let _currentNodeIndex: number;
|
||||
let _currentNodeIndex: number|null;
|
||||
|
||||
function debugSetCurrentNode(view: ViewData, nodeIndex: number) {
|
||||
function debugSetCurrentNode(view: ViewData, nodeIndex: number | null) {
|
||||
_currentView = view;
|
||||
_currentNodeIndex = nodeIndex;
|
||||
}
|
||||
|
@ -231,13 +231,13 @@ function debugCheckAndUpdateNode(
|
|||
const binding = nodeDef.bindings[i];
|
||||
const value = values[i];
|
||||
if (binding.flags & BindingFlags.TypeProperty) {
|
||||
bindingValues[normalizeDebugBindingName(binding.nonMinifiedName)] =
|
||||
bindingValues[normalizeDebugBindingName(binding.nonMinifiedName !)] =
|
||||
normalizeDebugBindingValue(value);
|
||||
}
|
||||
}
|
||||
const elDef = nodeDef.parent;
|
||||
const elDef = nodeDef.parent !;
|
||||
const el = asElementData(view, elDef.index).renderElement;
|
||||
if (!elDef.element.name) {
|
||||
if (!elDef.element !.name) {
|
||||
// a comment.
|
||||
view.renderer.setValue(el, `bindings=${JSON.stringify(bindingValues, null, 2)}`);
|
||||
} else {
|
||||
|
@ -281,31 +281,31 @@ function normalizeDebugBindingValue(value: any): string {
|
|||
}
|
||||
}
|
||||
|
||||
function nextDirectiveWithBinding(view: ViewData, nodeIndex: number): number {
|
||||
function nextDirectiveWithBinding(view: ViewData, nodeIndex: number): number|null {
|
||||
for (let i = nodeIndex; i < view.def.nodes.length; i++) {
|
||||
const nodeDef = view.def.nodes[i];
|
||||
if (nodeDef.flags & NodeFlags.TypeDirective && nodeDef.bindings && nodeDef.bindings.length) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
|
||||
function nextRenderNodeWithBinding(view: ViewData, nodeIndex: number): number {
|
||||
function nextRenderNodeWithBinding(view: ViewData, nodeIndex: number): number|null {
|
||||
for (let i = nodeIndex; i < view.def.nodes.length; i++) {
|
||||
const nodeDef = view.def.nodes[i];
|
||||
if ((nodeDef.flags & NodeFlags.CatRenderNode) && nodeDef.bindings && nodeDef.bindings.length) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
|
||||
class DebugContext_ implements DebugContext {
|
||||
private nodeDef: NodeDef;
|
||||
private elView: ViewData;
|
||||
private elDef: NodeDef;
|
||||
constructor(public view: ViewData, public nodeIndex: number) {
|
||||
constructor(public view: ViewData, public nodeIndex: number|null) {
|
||||
if (nodeIndex == null) {
|
||||
this.nodeIndex = nodeIndex = 0;
|
||||
}
|
||||
|
@ -313,12 +313,12 @@ class DebugContext_ implements DebugContext {
|
|||
let elDef = this.nodeDef;
|
||||
let elView = view;
|
||||
while (elDef && (elDef.flags & NodeFlags.TypeElement) === 0) {
|
||||
elDef = elDef.parent;
|
||||
elDef = elDef.parent !;
|
||||
}
|
||||
if (!elDef) {
|
||||
while (!elDef && elView) {
|
||||
elDef = viewParentEl(elView);
|
||||
elView = elView.parent;
|
||||
elDef = viewParentEl(elView) !;
|
||||
elView = elView.parent !;
|
||||
}
|
||||
}
|
||||
this.elDef = elDef;
|
||||
|
@ -337,7 +337,7 @@ class DebugContext_ implements DebugContext {
|
|||
for (let i = this.elDef.index + 1; i <= this.elDef.index + this.elDef.childCount; i++) {
|
||||
const childDef = this.elView.def.nodes[i];
|
||||
if (childDef.flags & NodeFlags.CatProvider) {
|
||||
tokens.push(childDef.provider.token);
|
||||
tokens.push(childDef.provider !.token);
|
||||
}
|
||||
i += childDef.childCount;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ class DebugContext_ implements DebugContext {
|
|||
return NOOP;
|
||||
}
|
||||
};
|
||||
logViewDef.factory(nodeLogger);
|
||||
logViewDef.factory !(nodeLogger);
|
||||
if (currRenderNodeIndex < renderNodeIndex) {
|
||||
console.error('Illegal state: the ViewDefinitionFactory did not call the logger!');
|
||||
(<any>console.error)(...values);
|
||||
|
@ -408,14 +408,14 @@ function getRenderNodeIndex(viewDef: ViewDefinition, nodeIndex: number): number
|
|||
return renderNodeIndex;
|
||||
}
|
||||
|
||||
function findHostElement(view: ViewData): ElementData {
|
||||
function findHostElement(view: ViewData): ElementData|null {
|
||||
while (view && !isComponentView(view)) {
|
||||
view = view.parent;
|
||||
view = view.parent !;
|
||||
}
|
||||
if (view.parent) {
|
||||
return asElementData(view.parent, viewParentEl(view).index);
|
||||
return asElementData(view.parent, viewParentEl(view) !.index);
|
||||
}
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
|
||||
function collectReferences(view: ViewData, nodeDef: NodeDef, references: {[key: string]: any}) {
|
||||
|
@ -440,11 +440,11 @@ function callWithDebugContext(action: DebugAction, fn: any, self: any, args: any
|
|||
throw e;
|
||||
}
|
||||
_currentView.state |= ViewState.Errored;
|
||||
throw viewWrappedDebugError(e, getCurrentDebugContext());
|
||||
throw viewWrappedDebugError(e, getCurrentDebugContext() !);
|
||||
}
|
||||
}
|
||||
|
||||
export function getCurrentDebugContext(): DebugContext {
|
||||
export function getCurrentDebugContext(): DebugContext|null {
|
||||
return _currentView ? new DebugContext_(_currentView, _currentNodeIndex) : null;
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ export function getCurrentDebugContext(): DebugContext {
|
|||
class DebugRendererFactory2 implements RendererFactory2 {
|
||||
constructor(private delegate: RendererFactory2) {}
|
||||
|
||||
createRenderer(element: any, renderData: RendererType2): Renderer2 {
|
||||
createRenderer(element: any, renderData: RendererType2|null): Renderer2 {
|
||||
return new DebugRenderer2(this.delegate.createRenderer(element, renderData));
|
||||
}
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ class DebugRenderer2 implements Renderer2 {
|
|||
get data() { return this.delegate.data; }
|
||||
|
||||
destroyNode(node: any) {
|
||||
removeDebugNodeFromIndex(getDebugNode(node));
|
||||
removeDebugNodeFromIndex(getDebugNode(node) !);
|
||||
if (this.delegate.destroyNode) {
|
||||
this.delegate.destroyNode(node);
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ class DebugRenderer2 implements Renderer2 {
|
|||
insertBefore(parent: any, newChild: any, refChild: any): void {
|
||||
const debugEl = getDebugNode(parent);
|
||||
const debugChildEl = getDebugNode(newChild);
|
||||
const debugRefEl = getDebugNode(refChild);
|
||||
const debugRefEl = getDebugNode(refChild) !;
|
||||
if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
|
||||
debugEl.insertBefore(debugRefEl, debugChildEl);
|
||||
}
|
||||
|
|
|
@ -14,21 +14,21 @@ export function textDef(ngContentIndex: number, constants: string[]): NodeDef {
|
|||
for (let i = 1; i < constants.length; i++) {
|
||||
bindings[i - 1] = {
|
||||
flags: BindingFlags.TypeProperty,
|
||||
name: undefined,
|
||||
ns: undefined,
|
||||
nonMinifiedName: undefined,
|
||||
securityContext: undefined,
|
||||
name: null,
|
||||
ns: null,
|
||||
nonMinifiedName: null,
|
||||
securityContext: null,
|
||||
suffix: constants[i]
|
||||
};
|
||||
}
|
||||
const flags = NodeFlags.TypeText;
|
||||
return {
|
||||
// will bet set by the view definition
|
||||
index: undefined,
|
||||
parent: undefined,
|
||||
renderParent: undefined,
|
||||
bindingIndex: undefined,
|
||||
outputIndex: undefined,
|
||||
index: -1,
|
||||
parent: null,
|
||||
renderParent: null,
|
||||
bindingIndex: -1,
|
||||
outputIndex: -1,
|
||||
// regular values
|
||||
flags,
|
||||
childFlags: 0,
|
||||
|
@ -40,18 +40,18 @@ export function textDef(ngContentIndex: number, constants: string[]): NodeDef {
|
|||
childCount: 0, bindings,
|
||||
bindingFlags: calcBindingFlags(bindings),
|
||||
outputs: [],
|
||||
element: undefined,
|
||||
provider: undefined,
|
||||
element: null,
|
||||
provider: null,
|
||||
text: {prefix: constants[0]},
|
||||
query: undefined,
|
||||
ngContent: undefined
|
||||
query: null,
|
||||
ngContent: null
|
||||
};
|
||||
}
|
||||
|
||||
export function createText(view: ViewData, renderHost: any, def: NodeDef): TextData {
|
||||
let renderNode: any;
|
||||
const renderer = view.renderer;
|
||||
renderNode = renderer.createText(def.text.prefix);
|
||||
renderNode = renderer.createText(def.text !.prefix);
|
||||
const parentEl = getParentRenderElement(view, renderHost, def);
|
||||
if (parentEl) {
|
||||
renderer.appendChild(parentEl, renderNode);
|
||||
|
@ -77,7 +77,7 @@ export function checkAndUpdateTextInline(
|
|||
if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9)) changed = true;
|
||||
|
||||
if (changed) {
|
||||
let value = def.text.prefix;
|
||||
let value = def.text !.prefix;
|
||||
if (bindLen > 0) value += _addInterpolationPart(v0, bindings[0]);
|
||||
if (bindLen > 1) value += _addInterpolationPart(v1, bindings[1]);
|
||||
if (bindLen > 2) value += _addInterpolationPart(v2, bindings[2]);
|
||||
|
@ -109,7 +109,7 @@ export function checkAndUpdateTextDynamic(view: ViewData, def: NodeDef, values:
|
|||
for (let i = 0; i < values.length; i++) {
|
||||
value = value + _addInterpolationPart(values[i], bindings[i]);
|
||||
}
|
||||
value = def.text.prefix + value;
|
||||
value = def.text !.prefix + value;
|
||||
const renderNode = asTextData(view, def.index).renderText;
|
||||
view.renderer.setValue(renderNode, value);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import {Sanitizer, SecurityContext} from '../security';
|
|||
// -------------------------------------
|
||||
|
||||
export interface ViewDefinition {
|
||||
factory: ViewDefinitionFactory;
|
||||
factory: ViewDefinitionFactory|null;
|
||||
flags: ViewFlags;
|
||||
updateDirectives: ViewUpdateFn;
|
||||
updateRenderer: ViewUpdateFn;
|
||||
|
@ -32,7 +32,7 @@ export interface ViewDefinition {
|
|||
/** aggregated NodeFlags for all nodes **/
|
||||
nodeFlags: NodeFlags;
|
||||
rootNodeFlags: NodeFlags;
|
||||
lastRenderRootNode: NodeDef;
|
||||
lastRenderRootNode: NodeDef|null;
|
||||
bindingCount: number;
|
||||
outputCount: number;
|
||||
/**
|
||||
|
@ -91,8 +91,8 @@ export const enum ViewFlags {
|
|||
export interface NodeDef {
|
||||
flags: NodeFlags;
|
||||
index: number;
|
||||
parent: NodeDef;
|
||||
renderParent: NodeDef;
|
||||
parent: NodeDef|null;
|
||||
renderParent: NodeDef|null;
|
||||
/** this is checked against NgContentDef.index to find matched nodes */
|
||||
ngContentIndex: number;
|
||||
/** number of transitive children */
|
||||
|
@ -123,11 +123,11 @@ export interface NodeDef {
|
|||
* Used as a bloom filter.
|
||||
*/
|
||||
childMatchedQueries: number;
|
||||
element: ElementDef;
|
||||
provider: ProviderDef;
|
||||
text: TextDef;
|
||||
query: QueryDef;
|
||||
ngContent: NgContentDef;
|
||||
element: ElementDef|null;
|
||||
provider: ProviderDef|null;
|
||||
text: TextDef|null;
|
||||
query: QueryDef|null;
|
||||
ngContent: NgContentDef|null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,11 +179,11 @@ export const enum NodeFlags {
|
|||
|
||||
export interface BindingDef {
|
||||
flags: BindingFlags;
|
||||
ns: string;
|
||||
name: string;
|
||||
nonMinifiedName: string;
|
||||
securityContext: SecurityContext;
|
||||
suffix: string;
|
||||
ns: string|null;
|
||||
name: string|null;
|
||||
nonMinifiedName: string|null;
|
||||
securityContext: SecurityContext|null;
|
||||
suffix: string|null;
|
||||
}
|
||||
|
||||
export const enum BindingFlags {
|
||||
|
@ -201,9 +201,9 @@ export const enum BindingFlags {
|
|||
|
||||
export interface OutputDef {
|
||||
type: OutputType;
|
||||
target: 'window'|'document'|'body'|'component';
|
||||
target: 'window'|'document'|'body'|'component'|null;
|
||||
eventName: string;
|
||||
propName: string;
|
||||
propName: string|null;
|
||||
}
|
||||
|
||||
export const enum OutputType {ElementOutput, DirectiveOutput}
|
||||
|
@ -217,26 +217,26 @@ export const enum QueryValueType {
|
|||
}
|
||||
|
||||
export interface ElementDef {
|
||||
name: string;
|
||||
ns: string;
|
||||
name: string|null;
|
||||
ns: string|null;
|
||||
/** ns, name, value */
|
||||
attrs: [string, string, string][];
|
||||
template: ViewDefinition;
|
||||
componentProvider: NodeDef;
|
||||
componentRendererType: RendererType2;
|
||||
attrs: [string, string, string][]|null;
|
||||
template: ViewDefinition|null;
|
||||
componentProvider: NodeDef|null;
|
||||
componentRendererType: RendererType2|null;
|
||||
// closure to allow recursive components
|
||||
componentView: ViewDefinitionFactory;
|
||||
componentView: ViewDefinitionFactory|null;
|
||||
/**
|
||||
* visible public providers for DI in the view,
|
||||
* as see from this element. This does not include private providers.
|
||||
*/
|
||||
publicProviders: {[tokenKey: string]: NodeDef};
|
||||
publicProviders: {[tokenKey: string]: NodeDef}|null;
|
||||
/**
|
||||
* same as visiblePublicProviders, but also includes private providers
|
||||
* that are located on this element.
|
||||
*/
|
||||
allProviders: {[tokenKey: string]: NodeDef};
|
||||
handleEvent: ElementHandleEventFn;
|
||||
allProviders: {[tokenKey: string]: NodeDef}|null;
|
||||
handleEvent: ElementHandleEventFn|null;
|
||||
}
|
||||
|
||||
export interface ElementHandleEventFn { (view: ViewData, eventName: string, event: any): boolean; }
|
||||
|
@ -303,9 +303,9 @@ export interface ViewData {
|
|||
root: RootData;
|
||||
renderer: Renderer2;
|
||||
// index of component provider / anchor.
|
||||
parentNodeDef: NodeDef;
|
||||
parent: ViewData;
|
||||
viewContainerParent: ViewData;
|
||||
parentNodeDef: NodeDef|null;
|
||||
parent: ViewData|null;
|
||||
viewContainerParent: ViewData|null;
|
||||
component: any;
|
||||
context: any;
|
||||
// Attention: Never loop over this, as this will
|
||||
|
@ -316,7 +316,7 @@ export interface ViewData {
|
|||
nodes: {[key: number]: NodeData};
|
||||
state: ViewState;
|
||||
oldValues: any[];
|
||||
disposables: DisposableFn[];
|
||||
disposables: DisposableFn[]|null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -366,7 +366,7 @@ export function asTextData(view: ViewData, index: number): TextData {
|
|||
export interface ElementData {
|
||||
renderElement: any;
|
||||
componentView: ViewData;
|
||||
viewContainer: ViewContainerData;
|
||||
viewContainer: ViewContainerData|null;
|
||||
template: TemplateData;
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ export interface RootData {
|
|||
|
||||
export abstract class DebugContext {
|
||||
abstract get view(): ViewData;
|
||||
abstract get nodeIndex(): number;
|
||||
abstract get nodeIndex(): number|null;
|
||||
abstract get injector(): Injector;
|
||||
abstract get component(): any;
|
||||
abstract get providerTokens(): any[];
|
||||
|
@ -461,7 +461,7 @@ export interface Services {
|
|||
checkNoChangesView(view: ViewData): void;
|
||||
destroyView(view: ViewData): void;
|
||||
resolveDep(
|
||||
view: ViewData, elDef: NodeDef, allowPrivateServices: boolean, depDef: DepDef,
|
||||
view: ViewData, elDef: NodeDef|null, allowPrivateServices: boolean, depDef: DepDef,
|
||||
notFoundValue?: any): any;
|
||||
createDebugContext(view: ViewData, nodeIndex: number): DebugContext;
|
||||
handleEvent: ViewHandleEventFn;
|
||||
|
@ -475,16 +475,16 @@ export interface Services {
|
|||
* debug mode can hook it. It is lazily filled when `isDevMode` is known.
|
||||
*/
|
||||
export const Services: Services = {
|
||||
setCurrentNode: undefined,
|
||||
createRootView: undefined,
|
||||
createEmbeddedView: undefined,
|
||||
checkAndUpdateView: undefined,
|
||||
checkNoChangesView: undefined,
|
||||
destroyView: undefined,
|
||||
resolveDep: undefined,
|
||||
createDebugContext: undefined,
|
||||
handleEvent: undefined,
|
||||
updateDirectives: undefined,
|
||||
updateRenderer: undefined,
|
||||
dirtyParentQueries: undefined,
|
||||
setCurrentNode: undefined !,
|
||||
createRootView: undefined !,
|
||||
createEmbeddedView: undefined !,
|
||||
checkAndUpdateView: undefined !,
|
||||
checkNoChangesView: undefined !,
|
||||
destroyView: undefined !,
|
||||
resolveDep: undefined !,
|
||||
createDebugContext: undefined !,
|
||||
handleEvent: undefined !,
|
||||
updateDirectives: undefined !,
|
||||
updateRenderer: undefined !,
|
||||
dirtyParentQueries: undefined !,
|
||||
};
|
||||
|
|
|
@ -60,7 +60,7 @@ export function createRendererType2(values: {
|
|||
|
||||
let _renderCompCount = 0;
|
||||
|
||||
export function resolveRendererType2(type: RendererType2): RendererType2 {
|
||||
export function resolveRendererType2(type?: RendererType2 | null): RendererType2|null {
|
||||
if (type && type.id === UNDEFINED_RENDERER_TYPE_ID) {
|
||||
// first time we see this RendererType2. Initialize it...
|
||||
const isFilled =
|
||||
|
@ -75,7 +75,7 @@ export function resolveRendererType2(type: RendererType2): RendererType2 {
|
|||
if (type && type.id === EMPTY_RENDERER_TYPE_ID) {
|
||||
type = null;
|
||||
}
|
||||
return type;
|
||||
return type || null;
|
||||
}
|
||||
|
||||
export function checkBinding(
|
||||
|
@ -108,7 +108,7 @@ export function checkBindingNoChanges(
|
|||
}
|
||||
|
||||
export function markParentViewsForCheck(view: ViewData) {
|
||||
let currView = view;
|
||||
let currView: ViewData|null = view;
|
||||
while (currView) {
|
||||
if (currView.def.flags & ViewFlags.OnPush) {
|
||||
currView.state |= ViewState.ChecksEnabled;
|
||||
|
@ -126,12 +126,12 @@ export function dispatchEvent(
|
|||
return Services.handleEvent(view, nodeIndex, eventName, event);
|
||||
}
|
||||
|
||||
export function declaredViewContainer(view: ViewData): ElementData {
|
||||
export function declaredViewContainer(view: ViewData): ElementData|null {
|
||||
if (view.parent) {
|
||||
const parentView = view.parent;
|
||||
return asElementData(parentView, view.parentNodeDef.index);
|
||||
return asElementData(parentView, view.parentNodeDef !.index);
|
||||
}
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,10 +139,10 @@ export function declaredViewContainer(view: ViewData): ElementData {
|
|||
* for embedded views, this is the index of the parent node
|
||||
* that contains the view container.
|
||||
*/
|
||||
export function viewParentEl(view: ViewData): NodeDef {
|
||||
export function viewParentEl(view: ViewData): NodeDef|null {
|
||||
const parentView = view.parent;
|
||||
if (parentView) {
|
||||
return view.parentNodeDef.parent;
|
||||
return view.parentNodeDef !.parent;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -157,23 +157,24 @@ export function renderNode(view: ViewData, def: NodeDef): any {
|
|||
}
|
||||
}
|
||||
|
||||
export function elementEventFullName(target: string, name: string): string {
|
||||
export function elementEventFullName(target: string | null, name: string): string {
|
||||
return target ? `${target}:${name}` : name;
|
||||
}
|
||||
|
||||
export function isComponentView(view: ViewData): boolean {
|
||||
return !!view.parent && !!(view.parentNodeDef.flags & NodeFlags.Component);
|
||||
return !!view.parent && !!(view.parentNodeDef !.flags & NodeFlags.Component);
|
||||
}
|
||||
|
||||
export function isEmbeddedView(view: ViewData): boolean {
|
||||
return !!view.parent && !(view.parentNodeDef.flags & NodeFlags.Component);
|
||||
return !!view.parent && !(view.parentNodeDef !.flags & NodeFlags.Component);
|
||||
}
|
||||
|
||||
export function filterQueryId(queryId: number): number {
|
||||
return 1 << (queryId % 32);
|
||||
}
|
||||
|
||||
export function splitMatchedQueriesDsl(matchedQueriesDsl: [string | number, QueryValueType][]): {
|
||||
export function splitMatchedQueriesDsl(
|
||||
matchedQueriesDsl: [string | number, QueryValueType][] | null): {
|
||||
matchedQueries: {[queryId: string]: QueryValueType},
|
||||
references: {[refId: string]: QueryValueType},
|
||||
matchedQueryIds: number
|
||||
|
@ -199,11 +200,12 @@ export function getParentRenderElement(view: ViewData, renderHost: any, def: Nod
|
|||
if (renderParent) {
|
||||
if ((renderParent.flags & NodeFlags.TypeElement) === 0 ||
|
||||
(renderParent.flags & NodeFlags.ComponentView) === 0 ||
|
||||
(renderParent.element.componentRendererType &&
|
||||
renderParent.element.componentRendererType.encapsulation === ViewEncapsulation.Native)) {
|
||||
(renderParent.element !.componentRendererType &&
|
||||
renderParent.element !.componentRendererType !.encapsulation ===
|
||||
ViewEncapsulation.Native)) {
|
||||
// only children of non components, or children of components with native encapsulation should
|
||||
// be attached.
|
||||
return asElementData(view, def.renderParent.index).renderElement;
|
||||
return asElementData(view, def.renderParent !.index).renderElement;
|
||||
}
|
||||
} else {
|
||||
return renderHost;
|
||||
|
@ -213,7 +215,7 @@ export function getParentRenderElement(view: ViewData, renderHost: any, def: Nod
|
|||
const VIEW_DEFINITION_CACHE = new WeakMap<any, ViewDefinition>();
|
||||
|
||||
export function resolveViewDefinition(factory: ViewDefinitionFactory): ViewDefinition {
|
||||
let value: ViewDefinition = VIEW_DEFINITION_CACHE.get(factory);
|
||||
let value: ViewDefinition = VIEW_DEFINITION_CACHE.get(factory) !;
|
||||
if (!value) {
|
||||
value = factory(() => NOOP);
|
||||
value.factory = factory;
|
||||
|
@ -231,10 +233,10 @@ export function rootRenderNodes(view: ViewData): any[] {
|
|||
export const enum RenderNodeAction {Collect, AppendChild, InsertBefore, RemoveChild}
|
||||
|
||||
export function visitRootRenderNodes(
|
||||
view: ViewData, action: RenderNodeAction, parentNode: any, nextSibling: any, target: any[]) {
|
||||
view: ViewData, action: RenderNodeAction, parentNode: any, nextSibling: any, target?: any[]) {
|
||||
// We need to re-compute the parent node in case the nodes have been moved around manually
|
||||
if (action === RenderNodeAction.RemoveChild) {
|
||||
parentNode = view.renderer.parentNode(renderNode(view, view.def.lastRenderRootNode));
|
||||
parentNode = view.renderer.parentNode(renderNode(view, view.def.lastRenderRootNode !));
|
||||
}
|
||||
visitSiblingRenderNodes(
|
||||
view, action, 0, view.def.nodes.length - 1, parentNode, nextSibling, target);
|
||||
|
@ -242,7 +244,7 @@ export function visitRootRenderNodes(
|
|||
|
||||
export function visitSiblingRenderNodes(
|
||||
view: ViewData, action: RenderNodeAction, startIndex: number, endIndex: number, parentNode: any,
|
||||
nextSibling: any, target: any[]) {
|
||||
nextSibling: any, target?: any[]) {
|
||||
for (let i = startIndex; i <= endIndex; i++) {
|
||||
const nodeDef = view.def.nodes[i];
|
||||
if (nodeDef.flags & (NodeFlags.TypeElement | NodeFlags.TypeText | NodeFlags.TypeNgContent)) {
|
||||
|
@ -255,24 +257,24 @@ export function visitSiblingRenderNodes(
|
|||
|
||||
export function visitProjectedRenderNodes(
|
||||
view: ViewData, ngContentIndex: number, action: RenderNodeAction, parentNode: any,
|
||||
nextSibling: any, target: any[]) {
|
||||
let compView = view;
|
||||
nextSibling: any, target?: any[]) {
|
||||
let compView: ViewData|null = view;
|
||||
while (compView && !isComponentView(compView)) {
|
||||
compView = compView.parent;
|
||||
}
|
||||
const hostView = compView.parent;
|
||||
const hostElDef = viewParentEl(compView);
|
||||
const startIndex = hostElDef.index + 1;
|
||||
const endIndex = hostElDef.index + hostElDef.childCount;
|
||||
const hostView = compView !.parent;
|
||||
const hostElDef = viewParentEl(compView !);
|
||||
const startIndex = hostElDef !.index + 1;
|
||||
const endIndex = hostElDef !.index + hostElDef !.childCount;
|
||||
for (let i = startIndex; i <= endIndex; i++) {
|
||||
const nodeDef = hostView.def.nodes[i];
|
||||
const nodeDef = hostView !.def.nodes[i];
|
||||
if (nodeDef.ngContentIndex === ngContentIndex) {
|
||||
visitRenderNode(hostView, nodeDef, action, parentNode, nextSibling, target);
|
||||
visitRenderNode(hostView !, nodeDef, action, parentNode, nextSibling, target);
|
||||
}
|
||||
// jump to next sibling
|
||||
i += nodeDef.childCount;
|
||||
}
|
||||
if (!hostView.parent) {
|
||||
if (!hostView !.parent) {
|
||||
// a root view
|
||||
const projectedNodes = view.root.projectableNodes[ngContentIndex];
|
||||
if (projectedNodes) {
|
||||
|
@ -285,10 +287,10 @@ export function visitProjectedRenderNodes(
|
|||
|
||||
function visitRenderNode(
|
||||
view: ViewData, nodeDef: NodeDef, action: RenderNodeAction, parentNode: any, nextSibling: any,
|
||||
target: any[]) {
|
||||
target?: any[]) {
|
||||
if (nodeDef.flags & NodeFlags.TypeNgContent) {
|
||||
visitProjectedRenderNodes(
|
||||
view, nodeDef.ngContent.index, action, parentNode, nextSibling, target);
|
||||
view, nodeDef.ngContent !.index, action, parentNode, nextSibling, target);
|
||||
} else {
|
||||
const rn = renderNode(view, nodeDef);
|
||||
if (action === RenderNodeAction.RemoveChild && (nodeDef.flags & NodeFlags.ComponentView) &&
|
||||
|
@ -305,12 +307,12 @@ function visitRenderNode(
|
|||
execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
|
||||
}
|
||||
if (nodeDef.flags & NodeFlags.EmbeddedViews) {
|
||||
const embeddedViews = asElementData(view, nodeDef.index).viewContainer._embeddedViews;
|
||||
const embeddedViews = asElementData(view, nodeDef.index).viewContainer !._embeddedViews;
|
||||
for (let k = 0; k < embeddedViews.length; k++) {
|
||||
visitRootRenderNodes(embeddedViews[k], action, parentNode, nextSibling, target);
|
||||
}
|
||||
}
|
||||
if (nodeDef.flags & NodeFlags.TypeElement && !nodeDef.element.name) {
|
||||
if (nodeDef.flags & NodeFlags.TypeElement && !nodeDef.element !.name) {
|
||||
visitSiblingRenderNodes(
|
||||
view, action, nodeDef.index + 1, nodeDef.index + nodeDef.childCount, parentNode,
|
||||
nextSibling, target);
|
||||
|
@ -320,7 +322,7 @@ function visitRenderNode(
|
|||
|
||||
function execRenderNodeAction(
|
||||
view: ViewData, renderNode: any, action: RenderNodeAction, parentNode: any, nextSibling: any,
|
||||
target: any[]) {
|
||||
target?: any[]) {
|
||||
const renderer = view.renderer;
|
||||
switch (action) {
|
||||
case RenderNodeAction.AppendChild:
|
||||
|
@ -333,7 +335,7 @@ function execRenderNodeAction(
|
|||
renderer.removeChild(parentNode, renderNode);
|
||||
break;
|
||||
case RenderNodeAction.Collect:
|
||||
target.push(renderNode);
|
||||
target !.push(renderNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -342,7 +344,7 @@ const NS_PREFIX_RE = /^:([^:]+):(.+)$/;
|
|||
|
||||
export function splitNamespace(name: string): string[] {
|
||||
if (name[0] === ':') {
|
||||
const match = name.match(NS_PREFIX_RE);
|
||||
const match = name.match(NS_PREFIX_RE) !;
|
||||
return [match[1], match[2]];
|
||||
}
|
||||
return ['', name];
|
||||
|
|
|
@ -28,15 +28,15 @@ export function viewDef(
|
|||
let viewNodeFlags = 0;
|
||||
let viewRootNodeFlags = 0;
|
||||
let viewMatchedQueries = 0;
|
||||
let currentParent: NodeDef = null;
|
||||
let currentParent: NodeDef|null = null;
|
||||
let currentElementHasPublicProviders = false;
|
||||
let currentElementHasPrivateProviders = false;
|
||||
let lastRenderRootNode: NodeDef = null;
|
||||
let lastRenderRootNode: NodeDef|null = null;
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
while (currentParent && i > currentParent.index + currentParent.childCount) {
|
||||
const newParent = currentParent.parent;
|
||||
const newParent: NodeDef|null = currentParent.parent;
|
||||
if (newParent) {
|
||||
newParent.childFlags |= currentParent.childFlags;
|
||||
newParent.childFlags |= currentParent.childFlags !;
|
||||
newParent.childMatchedQueries |= currentParent.childMatchedQueries;
|
||||
}
|
||||
currentParent = newParent;
|
||||
|
@ -48,9 +48,9 @@ export function viewDef(
|
|||
node.outputIndex = viewDisposableCount;
|
||||
|
||||
// renderParent needs to account for ng-container!
|
||||
let currentRenderParent: NodeDef;
|
||||
let currentRenderParent: NodeDef|null;
|
||||
if (currentParent && currentParent.flags & NodeFlags.TypeElement &&
|
||||
!currentParent.element.name) {
|
||||
!currentParent.element !.name) {
|
||||
currentRenderParent = currentParent.renderParent;
|
||||
} else {
|
||||
currentRenderParent = currentParent;
|
||||
|
@ -60,7 +60,7 @@ export function viewDef(
|
|||
if (node.element) {
|
||||
const elDef = node.element;
|
||||
elDef.publicProviders =
|
||||
currentParent ? currentParent.element.publicProviders : Object.create(null);
|
||||
currentParent ? currentParent.element !.publicProviders : Object.create(null);
|
||||
elDef.allProviders = elDef.publicProviders;
|
||||
// Note: We assume that all providers of an element are before any child element!
|
||||
currentElementHasPublicProviders = false;
|
||||
|
@ -94,24 +94,25 @@ export function viewDef(
|
|||
if (!currentElementHasPublicProviders) {
|
||||
currentElementHasPublicProviders = true;
|
||||
// Use prototypical inheritance to not get O(n^2) complexity...
|
||||
currentParent.element.publicProviders =
|
||||
Object.create(currentParent.element.publicProviders);
|
||||
currentParent.element.allProviders = currentParent.element.publicProviders;
|
||||
currentParent !.element !.publicProviders =
|
||||
Object.create(currentParent !.element !.publicProviders);
|
||||
currentParent !.element !.allProviders = currentParent !.element !.publicProviders;
|
||||
}
|
||||
const isPrivateService = (node.flags & NodeFlags.PrivateProvider) !== 0;
|
||||
const isComponent = (node.flags & NodeFlags.Component) !== 0;
|
||||
if (!isPrivateService || isComponent) {
|
||||
currentParent.element.publicProviders[node.provider.tokenKey] = node;
|
||||
currentParent !.element !.publicProviders ![node.provider !.tokenKey] = node;
|
||||
} else {
|
||||
if (!currentElementHasPrivateProviders) {
|
||||
currentElementHasPrivateProviders = true;
|
||||
// Use protoyypical inheritance to not get O(n^2) complexity...
|
||||
currentParent.element.allProviders = Object.create(currentParent.element.publicProviders);
|
||||
currentParent !.element !.allProviders =
|
||||
Object.create(currentParent !.element !.publicProviders);
|
||||
}
|
||||
currentParent.element.allProviders[node.provider.tokenKey] = node;
|
||||
currentParent !.element !.allProviders ![node.provider !.tokenKey] = node;
|
||||
}
|
||||
if (isComponent) {
|
||||
currentParent.element.componentProvider = node;
|
||||
currentParent !.element !.componentProvider = node;
|
||||
}
|
||||
}
|
||||
if (node.childCount) {
|
||||
|
@ -127,10 +128,10 @@ export function viewDef(
|
|||
currentParent = newParent;
|
||||
}
|
||||
const handleEvent: ViewHandleEventFn = (view, nodeIndex, eventName, event) =>
|
||||
nodes[nodeIndex].element.handleEvent(view, eventName, event);
|
||||
nodes[nodeIndex].element !.handleEvent !(view, eventName, event);
|
||||
return {
|
||||
// Will be filled later...
|
||||
factory: undefined,
|
||||
factory: null,
|
||||
nodeFlags: viewNodeFlags,
|
||||
rootNodeFlags: viewRootNodeFlags,
|
||||
nodeMatchedQueries: viewMatchedQueries, flags,
|
||||
|
@ -143,7 +144,7 @@ export function viewDef(
|
|||
};
|
||||
}
|
||||
|
||||
function validateNode(parent: NodeDef, node: NodeDef, nodeCount: number) {
|
||||
function validateNode(parent: NodeDef | null, node: NodeDef, nodeCount: number) {
|
||||
const template = node.element && node.element.template;
|
||||
if (template) {
|
||||
if (!template.lastRenderRootNode) {
|
||||
|
@ -156,7 +157,7 @@ function validateNode(parent: NodeDef, node: NodeDef, nodeCount: number) {
|
|||
}
|
||||
}
|
||||
if (node.flags & NodeFlags.CatProvider) {
|
||||
const parentFlags = parent ? parent.flags : null;
|
||||
const parentFlags = parent ? parent.flags : 0;
|
||||
if ((parentFlags & NodeFlags.TypeElement) === 0) {
|
||||
throw new Error(
|
||||
`Illegal State: Provider/Directive nodes need to be children of elements or anchors, at index ${node.index}!`);
|
||||
|
@ -186,7 +187,7 @@ export function createEmbeddedView(parent: ViewData, anchorDef: NodeDef, context
|
|||
// embedded views are seen as siblings to the anchor, so we need
|
||||
// to get the parent of the anchor and use it as parentIndex.
|
||||
const view =
|
||||
createView(parent.root, parent.renderer, parent, anchorDef, anchorDef.element.template);
|
||||
createView(parent.root, parent.renderer, parent, anchorDef, anchorDef.element !.template !);
|
||||
initView(view, parent.component, context);
|
||||
createViewNodes(view);
|
||||
return view;
|
||||
|
@ -200,16 +201,16 @@ export function createRootView(root: RootData, def: ViewDefinition, context?: an
|
|||
}
|
||||
|
||||
function createView(
|
||||
root: RootData, renderer: Renderer2, parent: ViewData, parentNodeDef: NodeDef,
|
||||
root: RootData, renderer: Renderer2, parent: ViewData | null, parentNodeDef: NodeDef | null,
|
||||
def: ViewDefinition): ViewData {
|
||||
const nodes: NodeData[] = new Array(def.nodes.length);
|
||||
const disposables = def.outputCount ? new Array(def.outputCount) : undefined;
|
||||
const disposables = def.outputCount ? new Array(def.outputCount) : null;
|
||||
const view: ViewData = {
|
||||
def,
|
||||
parent,
|
||||
viewContainerParent: undefined, parentNodeDef,
|
||||
context: undefined,
|
||||
component: undefined, nodes,
|
||||
viewContainerParent: null, parentNodeDef,
|
||||
context: null,
|
||||
component: null, nodes,
|
||||
state: ViewState.FirstCheck | ViewState.ChecksEnabled, root, renderer,
|
||||
oldValues: new Array(def.bindingCount), disposables
|
||||
};
|
||||
|
@ -225,7 +226,7 @@ function createViewNodes(view: ViewData) {
|
|||
let renderHost: any;
|
||||
if (isComponentView(view)) {
|
||||
const hostDef = view.parentNodeDef;
|
||||
renderHost = asElementData(view.parent, hostDef.parent.index).renderElement;
|
||||
renderHost = asElementData(view.parent !, hostDef !.parent !.index).renderElement;
|
||||
}
|
||||
const def = view.def;
|
||||
const nodes = view.nodes;
|
||||
|
@ -236,10 +237,10 @@ function createViewNodes(view: ViewData) {
|
|||
switch (nodeDef.flags & NodeFlags.Types) {
|
||||
case NodeFlags.TypeElement:
|
||||
const el = createElement(view, renderHost, nodeDef) as any;
|
||||
let componentView: ViewData;
|
||||
let componentView: ViewData = undefined !;
|
||||
if (nodeDef.flags & NodeFlags.ComponentView) {
|
||||
const compViewDef = resolveViewDefinition(nodeDef.element.componentView);
|
||||
const rendererType = nodeDef.element.componentRendererType;
|
||||
const compViewDef = resolveViewDefinition(nodeDef.element !.componentView !);
|
||||
const rendererType = nodeDef.element !.componentRendererType;
|
||||
let compRenderer: Renderer2;
|
||||
if (!rendererType) {
|
||||
compRenderer = view.root.renderer;
|
||||
|
@ -247,14 +248,14 @@ function createViewNodes(view: ViewData) {
|
|||
compRenderer = view.root.rendererFactory.createRenderer(el, rendererType);
|
||||
}
|
||||
componentView = createView(
|
||||
view.root, compRenderer, view, nodeDef.element.componentProvider, compViewDef);
|
||||
view.root, compRenderer, view, nodeDef.element !.componentProvider, compViewDef);
|
||||
}
|
||||
listenToElementOutputs(view, componentView, nodeDef, el);
|
||||
nodeData = <ElementData>{
|
||||
renderElement: el,
|
||||
componentView,
|
||||
viewContainer: undefined,
|
||||
template: nodeDef.element.template ? createTemplateData(view, nodeDef) : undefined
|
||||
viewContainer: null,
|
||||
template: nodeDef.element !.template ? createTemplateData(view, nodeDef) : undefined
|
||||
};
|
||||
if (nodeDef.flags & NodeFlags.EmbeddedViews) {
|
||||
nodeData.viewContainer = createViewContainerData(view, nodeDef, nodeData);
|
||||
|
@ -280,7 +281,7 @@ function createViewNodes(view: ViewData) {
|
|||
const instance = createDirectiveInstance(view, nodeDef);
|
||||
nodeData = <ProviderData>{instance};
|
||||
if (nodeDef.flags & NodeFlags.Component) {
|
||||
const compView = asElementData(view, nodeDef.parent.index).componentView;
|
||||
const compView = asElementData(view, nodeDef.parent !.index).componentView;
|
||||
initView(compView, instance, instance);
|
||||
}
|
||||
break;
|
||||
|
@ -451,8 +452,8 @@ function checkNoChangesQuery(view: ViewData, nodeDef: NodeDef) {
|
|||
const queryList = asQueryList(view, nodeDef.index);
|
||||
if (queryList.dirty) {
|
||||
throw expressionChangedAfterItHasBeenCheckedError(
|
||||
Services.createDebugContext(view, nodeDef.index), `Query ${nodeDef.query.id} not dirty`,
|
||||
`Query ${nodeDef.query.id} dirty`, (view.state & ViewState.FirstCheck) !== 0);
|
||||
Services.createDebugContext(view, nodeDef.index), `Query ${nodeDef.query!.id} not dirty`,
|
||||
`Query ${nodeDef.query!.id} dirty`, (view.state & ViewState.FirstCheck) !== 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,9 +483,9 @@ function destroyViewNodes(view: ViewData) {
|
|||
for (let i = 0; i < len; i++) {
|
||||
const def = view.def.nodes[i];
|
||||
if (def.flags & NodeFlags.TypeElement) {
|
||||
view.renderer.destroyNode(asElementData(view, i).renderElement);
|
||||
view.renderer.destroyNode !(asElementData(view, i).renderElement);
|
||||
} else if (def.flags & NodeFlags.TypeText) {
|
||||
view.renderer.destroyNode(asTextData(view, i).renderText);
|
||||
view.renderer.destroyNode !(asTextData(view, i).renderText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -524,7 +525,7 @@ function execEmbeddedViewsAction(view: ViewData, action: ViewAction) {
|
|||
const nodeDef = def.nodes[i];
|
||||
if (nodeDef.flags & NodeFlags.EmbeddedViews) {
|
||||
// a leaf
|
||||
const embeddedViews = asElementData(view, i).viewContainer._embeddedViews;
|
||||
const embeddedViews = asElementData(view, i).viewContainer !._embeddedViews;
|
||||
for (let k = 0; k < embeddedViews.length; k++) {
|
||||
callViewAction(embeddedViews[k], action);
|
||||
}
|
||||
|
|
|
@ -10,13 +10,14 @@ import {ElementData, Services, ViewData} from './types';
|
|||
import {RenderNodeAction, declaredViewContainer, renderNode, visitRootRenderNodes} from './util';
|
||||
|
||||
export function attachEmbeddedView(
|
||||
parentView: ViewData, elementData: ElementData, viewIndex: number, view: ViewData) {
|
||||
let embeddedViews = elementData.viewContainer._embeddedViews;
|
||||
if (viewIndex == null) {
|
||||
parentView: ViewData, elementData: ElementData, viewIndex: number | undefined | null,
|
||||
view: ViewData) {
|
||||
let embeddedViews = elementData.viewContainer !._embeddedViews;
|
||||
if (viewIndex === null || viewIndex === undefined) {
|
||||
viewIndex = embeddedViews.length;
|
||||
}
|
||||
view.viewContainerParent = parentView;
|
||||
addToArray(embeddedViews, viewIndex, view);
|
||||
addToArray(embeddedViews, viewIndex !, view);
|
||||
const dvcElementData = declaredViewContainer(view);
|
||||
if (dvcElementData && dvcElementData !== elementData) {
|
||||
let projectedViews = dvcElementData.template._projectedViews;
|
||||
|
@ -28,12 +29,12 @@ export function attachEmbeddedView(
|
|||
|
||||
Services.dirtyParentQueries(view);
|
||||
|
||||
const prevView = viewIndex > 0 ? embeddedViews[viewIndex - 1] : null;
|
||||
const prevView = viewIndex ! > 0 ? embeddedViews[viewIndex ! - 1] : null;
|
||||
renderAttachEmbeddedView(elementData, prevView, view);
|
||||
}
|
||||
|
||||
export function detachEmbeddedView(elementData: ElementData, viewIndex: number): ViewData {
|
||||
const embeddedViews = elementData.viewContainer._embeddedViews;
|
||||
export function detachEmbeddedView(elementData: ElementData, viewIndex?: number): ViewData|null {
|
||||
const embeddedViews = elementData.viewContainer !._embeddedViews;
|
||||
if (viewIndex == null || viewIndex >= embeddedViews.length) {
|
||||
viewIndex = embeddedViews.length - 1;
|
||||
}
|
||||
|
@ -41,7 +42,7 @@ export function detachEmbeddedView(elementData: ElementData, viewIndex: number):
|
|||
return null;
|
||||
}
|
||||
const view = embeddedViews[viewIndex];
|
||||
view.viewContainerParent = undefined;
|
||||
view.viewContainerParent = null;
|
||||
removeFromArray(embeddedViews, viewIndex);
|
||||
|
||||
const dvcElementData = declaredViewContainer(view);
|
||||
|
@ -59,7 +60,7 @@ export function detachEmbeddedView(elementData: ElementData, viewIndex: number):
|
|||
|
||||
export function moveEmbeddedView(
|
||||
elementData: ElementData, oldViewIndex: number, newViewIndex: number): ViewData {
|
||||
const embeddedViews = elementData.viewContainer._embeddedViews;
|
||||
const embeddedViews = elementData.viewContainer !._embeddedViews;
|
||||
const view = embeddedViews[oldViewIndex];
|
||||
removeFromArray(embeddedViews, oldViewIndex);
|
||||
if (newViewIndex == null) {
|
||||
|
@ -79,9 +80,10 @@ export function moveEmbeddedView(
|
|||
return view;
|
||||
}
|
||||
|
||||
function renderAttachEmbeddedView(elementData: ElementData, prevView: ViewData, view: ViewData) {
|
||||
const prevRenderNode =
|
||||
prevView ? renderNode(prevView, prevView.def.lastRenderRootNode) : elementData.renderElement;
|
||||
function renderAttachEmbeddedView(
|
||||
elementData: ElementData, prevView: ViewData | null, view: ViewData) {
|
||||
const prevRenderNode = prevView ? renderNode(prevView, prevView.def.lastRenderRootNode !) :
|
||||
elementData.renderElement;
|
||||
const parentNode = view.renderer.parentNode(prevRenderNode);
|
||||
const nextSibling = view.renderer.nextSibling(prevRenderNode);
|
||||
// Note: We can't check if `nextSibling` is present, as on WebWorkers it will always be!
|
||||
|
|
|
@ -60,7 +60,7 @@ export function main() {
|
|||
engine.flush();
|
||||
|
||||
expect(getLog().length).toEqual(1);
|
||||
expect(getLog().pop().keyframes).toEqual([
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, opacity: '0'}, {offset: 1, opacity: '1'}
|
||||
]);
|
||||
});
|
||||
|
@ -96,7 +96,7 @@ export function main() {
|
|||
fixture.detectChanges();
|
||||
engine.flush();
|
||||
|
||||
expect(getLog().pop().keyframes).toEqual([
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, width: '0px'}, {offset: 1, width: '100px'}
|
||||
]);
|
||||
|
||||
|
@ -105,7 +105,7 @@ export function main() {
|
|||
fixture.detectChanges();
|
||||
engine.flush();
|
||||
|
||||
expect(getLog().pop().keyframes).toEqual([
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, height: '0px'}, {offset: 1, height: '100px'}
|
||||
]);
|
||||
|
||||
|
@ -114,7 +114,7 @@ export function main() {
|
|||
fixture.detectChanges();
|
||||
engine.flush();
|
||||
|
||||
expect(getLog().pop().keyframes).toEqual([
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, height: '0px'}, {offset: 1, height: '100px'}
|
||||
]);
|
||||
|
||||
|
@ -123,7 +123,7 @@ export function main() {
|
|||
fixture.detectChanges();
|
||||
engine.flush();
|
||||
|
||||
expect(getLog().pop().keyframes).toEqual([
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, height: '0px'}, {offset: 1, height: '100px'}
|
||||
]);
|
||||
|
||||
|
@ -132,7 +132,7 @@ export function main() {
|
|||
fixture.detectChanges();
|
||||
engine.flush();
|
||||
|
||||
expect(getLog().pop().keyframes).toEqual([
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, height: '0px'}, {offset: 1, height: '100px'}
|
||||
]);
|
||||
|
||||
|
@ -142,7 +142,7 @@ export function main() {
|
|||
fixture.detectChanges();
|
||||
engine.flush();
|
||||
|
||||
expect(getLog().pop().keyframes).toEqual([
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, width: '0px'}, {offset: 1, width: '100px'}
|
||||
]);
|
||||
});
|
||||
|
@ -174,7 +174,7 @@ export function main() {
|
|||
fixture.detectChanges();
|
||||
engine.flush();
|
||||
|
||||
expect(getLog().pop().keyframes).toEqual([
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, opacity: '0'}, {offset: 1, opacity: '1'}
|
||||
]);
|
||||
|
||||
|
@ -182,7 +182,7 @@ export function main() {
|
|||
fixture.detectChanges();
|
||||
engine.flush();
|
||||
|
||||
expect(getLog().pop().keyframes).toEqual([
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, opacity: '1'}, {offset: 1, opacity: '0'}
|
||||
]);
|
||||
});
|
||||
|
@ -233,7 +233,7 @@ export function main() {
|
|||
engine.flush();
|
||||
expect(getLog().length).toEqual(1);
|
||||
|
||||
const data = getLog().pop();
|
||||
const data = getLog().pop() !;
|
||||
expect(data.element).toEqual(fixture.elementRef.nativeElement);
|
||||
expect(data.keyframes).toEqual([{offset: 0, opacity: '0'}, {offset: 1, opacity: '1'}]);
|
||||
}));
|
||||
|
@ -679,8 +679,8 @@ export function main() {
|
|||
|
||||
expect(getLog().length).toEqual(2);
|
||||
|
||||
const player2 = getLog().pop();
|
||||
const player1 = getLog().pop();
|
||||
const player2 = getLog().pop() !;
|
||||
const player1 = getLog().pop() !;
|
||||
|
||||
expect(player2.keyframes).toEqual([
|
||||
{width: AUTO_STYLE, offset: 0},
|
||||
|
@ -712,7 +712,7 @@ export function main() {
|
|||
]
|
||||
})
|
||||
class Cmp {
|
||||
public exp: string;
|
||||
public exp: string|null;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [Cmp]});
|
||||
|
|
|
@ -45,7 +45,7 @@ export function main() {
|
|||
|
||||
function createModule(providers?: any[]): Type<any>;
|
||||
function createModule(options: CreateModuleOptions): Type<any>;
|
||||
function createModule(providersOrOptions: any[] | CreateModuleOptions): Type<any> {
|
||||
function createModule(providersOrOptions: any[] | CreateModuleOptions | undefined): Type<any> {
|
||||
let options: CreateModuleOptions = {};
|
||||
if (providersOrOptions instanceof Array) {
|
||||
options = {providers: providersOrOptions};
|
||||
|
@ -92,7 +92,8 @@ export function main() {
|
|||
createRootEl();
|
||||
const modFactory = compiler.compileModuleSync(SomeModule);
|
||||
const module = modFactory.create(TestBed);
|
||||
const cmpFactory = module.componentFactoryResolver.resolveComponentFactory(SomeComponent);
|
||||
const cmpFactory =
|
||||
module.componentFactoryResolver.resolveComponentFactory(SomeComponent) !;
|
||||
const component = app.bootstrap(cmpFactory);
|
||||
|
||||
// The component should see the child module providers
|
||||
|
@ -388,7 +389,7 @@ export function main() {
|
|||
vc.insert(hostView);
|
||||
expect(() => appRef.attachView(hostView))
|
||||
.toThrowError('This view is already attached to a ViewContainer!');
|
||||
hostView = vc.detach(0);
|
||||
hostView = vc.detach(0) !;
|
||||
|
||||
appRef.attachView(hostView);
|
||||
expect(() => vc.insert(hostView))
|
||||
|
|
|
@ -309,7 +309,7 @@ export function main() {
|
|||
|
||||
function modifyArrayUsingOperation(
|
||||
arr: number[], endData: any[], prev: number, next: number) {
|
||||
let value: number = null;
|
||||
let value: number = null !;
|
||||
if (prev == null) {
|
||||
value = endData[next];
|
||||
arr.splice(next, 0, value);
|
||||
|
|
|
@ -21,7 +21,7 @@ export function main() {
|
|||
m = new Map();
|
||||
});
|
||||
|
||||
afterEach(() => { differ = null; });
|
||||
afterEach(() => { differ = null !; });
|
||||
|
||||
it('should detect additions', () => {
|
||||
differ.check(m);
|
||||
|
|
|
@ -318,7 +318,7 @@ export function main() {
|
|||
fixture = TestBed.createComponent(LocalsComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.debugElement.children[0].references['alice']).toBeAnInstanceOf(MyDir);
|
||||
expect(fixture.debugElement.children[0].references !['alice']).toBeAnInstanceOf(MyDir);
|
||||
});
|
||||
|
||||
it('should allow injecting from the element injector', () => {
|
||||
|
|
|
@ -79,7 +79,7 @@ export function main() {
|
|||
];
|
||||
|
||||
function createInjector(
|
||||
providers: Provider[], parent: ReflectiveInjector = null): ReflectiveInjector_ {
|
||||
providers: Provider[], parent?: ReflectiveInjector | null): ReflectiveInjector_ {
|
||||
const resolvedProviders = ReflectiveInjector.resolve(providers.concat(dynamicProviders));
|
||||
if (parent != null) {
|
||||
return <ReflectiveInjector_>parent.createChildFromResolved(resolvedProviders);
|
||||
|
|
|
@ -100,7 +100,7 @@ export function main() {
|
|||
const headEl = defaultDoc.head;
|
||||
getDOM().appendChild(headEl, baseEl);
|
||||
|
||||
const baseHref = getDOM().getBaseHref(defaultDoc);
|
||||
const baseHref = getDOM().getBaseHref(defaultDoc) !;
|
||||
getDOM().removeChild(headEl, baseEl);
|
||||
getDOM().resetBaseElement();
|
||||
|
||||
|
|
|
@ -261,14 +261,14 @@ export function main() {
|
|||
describe('safe navigation operator', () => {
|
||||
it('should support reading properties of nulls', fakeAsync(() => {
|
||||
const ctx = _bindSimpleValue('address?.city', Person);
|
||||
ctx.componentInstance.address = null;
|
||||
ctx.componentInstance.address = null !;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=null']);
|
||||
}));
|
||||
|
||||
it('should support calling methods on nulls', fakeAsync(() => {
|
||||
const ctx = _bindSimpleValue('address?.toString()', Person);
|
||||
ctx.componentInstance.address = null;
|
||||
ctx.componentInstance.address = null !;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=null']);
|
||||
}));
|
||||
|
@ -289,7 +289,7 @@ export function main() {
|
|||
|
||||
it('should support short-circuting safe navigation', fakeAsync(() => {
|
||||
const ctx = _bindSimpleValue('value?.address.city', PersonHolder);
|
||||
ctx.componentInstance.value = null;
|
||||
ctx.componentInstance.value = null !;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=null']);
|
||||
}));
|
||||
|
@ -317,7 +317,7 @@ export function main() {
|
|||
expect(() => {
|
||||
const ctx = _bindSimpleValue('value?.address.city', PersonHolder);
|
||||
const person = new Person();
|
||||
person.address = null;
|
||||
person.address = null !;
|
||||
ctx.componentInstance.value = person;
|
||||
ctx.detectChanges(false);
|
||||
}).toThrow();
|
||||
|
@ -553,7 +553,7 @@ export function main() {
|
|||
it('should call pure pipes only if the arguments change', fakeAsync(() => {
|
||||
const ctx = _bindSimpleValue('name | countingPipe', Person);
|
||||
// change from undefined -> null
|
||||
ctx.componentInstance.name = null;
|
||||
ctx.componentInstance.name = null !;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual(['null state:0']);
|
||||
ctx.detectChanges(false);
|
||||
|
@ -1620,10 +1620,10 @@ class TestLocals {
|
|||
class Person {
|
||||
age: number;
|
||||
name: string;
|
||||
address: Address = null;
|
||||
address: Address|null = null;
|
||||
phones: number[];
|
||||
|
||||
init(name: string, address: Address = null) {
|
||||
init(name: string, address: Address|null = null) {
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
const compFixture = TestBed.createComponent(MainComp);
|
||||
const mainComp: MainComp = compFixture.componentInstance;
|
||||
expect(compFixture.componentRef.injector.get(ComponentFactoryResolver)).toBe(mainComp.cfr);
|
||||
const cf = mainComp.cfr.resolveComponentFactory(ChildComp);
|
||||
const cf = mainComp.cfr.resolveComponentFactory(ChildComp) !;
|
||||
expect(cf.componentType).toBe(ChildComp);
|
||||
});
|
||||
|
||||
|
@ -51,8 +51,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
const mainComp: CompWithAnalyzeEntryComponentsProvider = compFixture.componentInstance;
|
||||
const cfr: ComponentFactoryResolver =
|
||||
compFixture.componentRef.injector.get(ComponentFactoryResolver);
|
||||
expect(cfr.resolveComponentFactory(ChildComp).componentType).toBe(ChildComp);
|
||||
expect(cfr.resolveComponentFactory(NestedChildComp).componentType).toBe(NestedChildComp);
|
||||
expect(cfr.resolveComponentFactory(ChildComp) !.componentType).toBe(ChildComp);
|
||||
expect(cfr.resolveComponentFactory(NestedChildComp) !.componentType).toBe(NestedChildComp);
|
||||
});
|
||||
|
||||
it('should be able to get a component form a parent component (view hiearchy)', () => {
|
||||
|
@ -62,10 +62,10 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
const childCompEl = compFixture.debugElement.children[0];
|
||||
const childComp: ChildComp = childCompEl.componentInstance;
|
||||
// declared on ChildComp directly
|
||||
expect(childComp.cfr.resolveComponentFactory(NestedChildComp).componentType)
|
||||
expect(childComp.cfr.resolveComponentFactory(NestedChildComp) !.componentType)
|
||||
.toBe(NestedChildComp);
|
||||
// inherited from MainComp
|
||||
expect(childComp.cfr.resolveComponentFactory(ChildComp).componentType).toBe(ChildComp);
|
||||
expect(childComp.cfr.resolveComponentFactory(ChildComp) !.componentType).toBe(ChildComp);
|
||||
});
|
||||
|
||||
it('should not be able to get components from a parent component (content hierarchy)', () => {
|
||||
|
@ -75,7 +75,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
const compFixture = TestBed.createComponent(MainComp);
|
||||
const nestedChildCompEl = compFixture.debugElement.children[0].children[0];
|
||||
const nestedChildComp: NestedChildComp = nestedChildCompEl.componentInstance;
|
||||
expect(nestedChildComp.cfr.resolveComponentFactory(ChildComp).componentType).toBe(ChildComp);
|
||||
expect(nestedChildComp.cfr.resolveComponentFactory(ChildComp) !.componentType)
|
||||
.toBe(ChildComp);
|
||||
expect(() => nestedChildComp.cfr.resolveComponentFactory(NestedChildComp))
|
||||
.toThrow(noComponentFactoryError(NestedChildComp));
|
||||
});
|
||||
|
|
|
@ -56,7 +56,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
const template = '<div>{{null}}{{ctxProp}}</div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
fixture.componentInstance.ctxProp = null;
|
||||
fixture.componentInstance.ctxProp = null !;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement).toHaveText('');
|
||||
|
@ -134,7 +134,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
expect(getDOM().getAttribute(fixture.debugElement.children[0].nativeElement, 'foo'))
|
||||
.toEqual('bar');
|
||||
|
||||
fixture.componentInstance.ctxProp = null;
|
||||
fixture.componentInstance.ctxProp = null !;
|
||||
fixture.detectChanges();
|
||||
expect(getDOM().hasAttribute(fixture.debugElement.children[0].nativeElement, 'foo'))
|
||||
.toBeFalsy();
|
||||
|
@ -151,7 +151,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'height'))
|
||||
.toEqual('10px');
|
||||
|
||||
fixture.componentInstance.ctxProp = null;
|
||||
fixture.componentInstance.ctxProp = null !;
|
||||
fixture.detectChanges();
|
||||
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'height'))
|
||||
.toEqual('');
|
||||
|
@ -264,7 +264,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
fixture.componentInstance.ctxProp = 'a';
|
||||
fixture.detectChanges();
|
||||
|
||||
const dir = fixture.debugElement.children[0].references['dir'];
|
||||
const dir = fixture.debugElement.children[0].references !['dir'];
|
||||
expect(dir.dirProp).toEqual('aa');
|
||||
});
|
||||
});
|
||||
|
@ -450,7 +450,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
expect(fixture.debugElement.children[0].children[0].references['alice'])
|
||||
expect(fixture.debugElement.children[0].children[0].references !['alice'])
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
});
|
||||
|
||||
|
@ -460,7 +460,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
expect(fixture.debugElement.children[0].children[0].references['localdir'])
|
||||
expect(fixture.debugElement.children[0].children[0].references !['localdir'])
|
||||
.toBeAnInstanceOf(ExportDir);
|
||||
});
|
||||
|
||||
|
@ -486,8 +486,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
|
||||
const pEl = fixture.debugElement.children[0];
|
||||
|
||||
const alice = pEl.children[0].references['alice'];
|
||||
const bob = pEl.children[1].references['bob'];
|
||||
const alice = pEl.children[0].references !['alice'];
|
||||
const bob = pEl.children[1].references !['bob'];
|
||||
expect(alice).toBeAnInstanceOf(ChildComp);
|
||||
expect(bob).toBeAnInstanceOf(ChildComp);
|
||||
expect(alice).not.toBe(bob);
|
||||
|
@ -499,7 +499,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
expect(fixture.debugElement.children[0].references['alice']).toBeAnInstanceOf(ChildComp);
|
||||
expect(fixture.debugElement.children[0].references !['alice'])
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
});
|
||||
|
||||
it('should assign the element instance to a user-defined variable', () => {
|
||||
|
@ -508,7 +509,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const value = fixture.debugElement.children[0].children[0].references['alice'];
|
||||
const value = fixture.debugElement.children[0].children[0].references !['alice'];
|
||||
expect(value).not.toBe(null);
|
||||
expect(value.tagName.toLowerCase()).toEqual('div');
|
||||
});
|
||||
|
@ -520,7 +521,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
MyComp, {set: {template: '<ng-template ref-alice></ng-template>'}})
|
||||
.createComponent(MyComp);
|
||||
|
||||
const value = fixture.debugElement.childNodes[0].references['alice'];
|
||||
const value = fixture.debugElement.childNodes[0].references !['alice'];
|
||||
expect(value.createEmbeddedView).toBeTruthy();
|
||||
});
|
||||
|
||||
|
@ -530,7 +531,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
expect(fixture.debugElement.children[0].children[0].references['superAlice'])
|
||||
expect(fixture.debugElement.children[0].children[0].references !['superAlice'])
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
});
|
||||
});
|
||||
|
@ -559,7 +560,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
const cmp = fixture.debugElement.children[0].references !['cmp'];
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
@ -580,7 +581,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
const cmp = fixture.debugElement.children[0].references !['cmp'];
|
||||
|
||||
fixture.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
|
@ -654,7 +655,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
const cmp = fixture.debugElement.children[0].references !['cmp'];
|
||||
|
||||
fixture.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
|
@ -675,7 +676,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
|
||||
tick();
|
||||
|
||||
const cmp: PushCmpWithAsyncPipe = fixture.debugElement.children[0].references['cmp'];
|
||||
const cmp: PushCmpWithAsyncPipe =
|
||||
fixture.debugElement.children[0].references !['cmp'];
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
|
@ -707,7 +709,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const childComponent =
|
||||
fixture.debugElement.children[0].children[0].children[0].references['child'];
|
||||
fixture.debugElement.children[0].children[0].children[0].references !['child'];
|
||||
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
|
||||
});
|
||||
|
||||
|
@ -729,7 +731,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
|
||||
const tc = fixture.debugElement.children[0].children[0].children[0];
|
||||
|
||||
const childComponent = tc.references['child'];
|
||||
const childComponent = tc.references !['child'];
|
||||
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
|
||||
});
|
||||
|
||||
|
@ -1232,7 +1234,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const comp = fixture.debugElement.children[0].children[0].references['consuming'];
|
||||
const comp = fixture.debugElement.children[0].children[0].references !['consuming'];
|
||||
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
|
||||
});
|
||||
|
||||
|
@ -1248,7 +1250,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(DirectiveProvidingInjectableInView, {set: {template}});
|
||||
const fixture = TestBed.createComponent(DirectiveProvidingInjectableInView);
|
||||
|
||||
const comp = fixture.debugElement.children[0].references['consuming'];
|
||||
const comp = fixture.debugElement.children[0].references !['consuming'];
|
||||
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
|
||||
});
|
||||
|
||||
|
@ -1276,7 +1278,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const comp = fixture.debugElement.children[0].children[0].references['dir'];
|
||||
const comp = fixture.debugElement.children[0].children[0].references !['dir'];
|
||||
expect(comp.directive.injectable).toBeAnInstanceOf(InjectableService);
|
||||
});
|
||||
|
||||
|
@ -1326,7 +1328,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const providing = fixture.debugElement.children[0].references['providing'];
|
||||
const providing = fixture.debugElement.children[0].references !['providing'];
|
||||
expect(providing.created).toBe(false);
|
||||
|
||||
fixture.componentInstance.ctxBoolProp = true;
|
||||
|
@ -1363,7 +1365,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
});
|
||||
|
||||
it('should use a default element name for components without selectors', () => {
|
||||
let noSelectorComponentFactory: ComponentFactory<SomeComponent>;
|
||||
let noSelectorComponentFactory: ComponentFactory<SomeComponent> = undefined !;
|
||||
|
||||
@Component({template: '----'})
|
||||
class NoSelectorComponent {
|
||||
|
@ -1374,7 +1376,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
constructor(componentFactoryResolver: ComponentFactoryResolver) {
|
||||
// grab its own component factory
|
||||
noSelectorComponentFactory =
|
||||
componentFactoryResolver.resolveComponentFactory(NoSelectorComponent);
|
||||
componentFactoryResolver.resolveComponentFactory(NoSelectorComponent) !;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1843,7 +1845,8 @@ class DynamicViewport {
|
|||
|
||||
this.injector = ReflectiveInjector.resolveAndCreate(
|
||||
[{provide: MyService, useValue: myService}], vc.injector);
|
||||
this.componentFactory = componentFactoryResolver.resolveComponentFactory(ChildCompUsingService);
|
||||
this.componentFactory =
|
||||
componentFactoryResolver.resolveComponentFactory(ChildCompUsingService) !;
|
||||
}
|
||||
|
||||
create() { this.vc.createComponent(this.componentFactory, this.vc.length, this.injector); }
|
||||
|
@ -1970,7 +1973,7 @@ class MyComp {
|
|||
})
|
||||
class ChildComp {
|
||||
ctxProp: string;
|
||||
dirProp: string;
|
||||
dirProp: string|null;
|
||||
constructor(service: MyService) {
|
||||
this.ctxProp = service.greeting;
|
||||
this.dirProp = null;
|
||||
|
@ -2006,7 +2009,7 @@ class CompWithHost {
|
|||
@Component({selector: '[child-cmp2]', viewProviders: [MyService]})
|
||||
class ChildComp2 {
|
||||
ctxProp: string;
|
||||
dirProp: string;
|
||||
dirProp: string|null;
|
||||
constructor(service: MyService) {
|
||||
this.ctxProp = service.greeting;
|
||||
this.dirProp = null;
|
||||
|
@ -2277,7 +2280,7 @@ class EventBus {
|
|||
|
||||
@Directive({
|
||||
selector: 'grand-parent-providing-event-bus',
|
||||
providers: [{provide: EventBus, useValue: new EventBus(null, 'grandparent')}]
|
||||
providers: [{provide: EventBus, useValue: new EventBus(null !, 'grandparent')}]
|
||||
})
|
||||
class GrandParentProvidingEventBus {
|
||||
bus: EventBus;
|
||||
|
@ -2313,7 +2316,7 @@ class ChildConsumingEventBus {
|
|||
|
||||
@Directive({selector: '[someImpvp]', inputs: ['someImpvp']})
|
||||
class SomeImperativeViewport {
|
||||
view: EmbeddedViewRef<Object>;
|
||||
view: EmbeddedViewRef<Object>|null;
|
||||
anchor: any;
|
||||
constructor(
|
||||
public vc: ViewContainerRef, public templateRef: TemplateRef<Object>,
|
||||
|
|
|
@ -132,7 +132,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
fixture.detectChanges();
|
||||
const q = fixture.debugElement.children[0].references['q'];
|
||||
const q = fixture.debugElement.children[0].references !['q'];
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(q.textDirChildren.length).toEqual(1);
|
||||
|
@ -145,7 +145,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
fixture.detectChanges();
|
||||
const q = fixture.debugElement.children[0].references['q'];
|
||||
const q = fixture.debugElement.children[0].references !['q'];
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(q.textDirChildren.length).toEqual(1);
|
||||
|
@ -156,7 +156,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
|
||||
@Directive({selector: '[text]'})
|
||||
class TextDirective {
|
||||
@Input() public text: string = null;
|
||||
@Input() public text: string|null = null;
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-content-children', template: ''})
|
||||
|
|
|
@ -125,18 +125,19 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
injector = _injector;
|
||||
}));
|
||||
|
||||
function createModule<T>(moduleType: Type<T>, parentInjector: Injector = null): NgModuleRef<T> {
|
||||
function createModule<T>(
|
||||
moduleType: Type<T>, parentInjector?: Injector | null): NgModuleRef<T> {
|
||||
return compiler.compileModuleSync(moduleType).create(parentInjector);
|
||||
}
|
||||
|
||||
function createComp<T>(compType: Type<T>, moduleType: Type<any>): ComponentFixture<T> {
|
||||
const ngModule = createModule(moduleType, injector);
|
||||
|
||||
const cf = ngModule.componentFactoryResolver.resolveComponentFactory(compType);
|
||||
const cf = ngModule.componentFactoryResolver.resolveComponentFactory(compType) !;
|
||||
|
||||
const comp = cf.create(Injector.NULL);
|
||||
|
||||
return new ComponentFixture(comp, null, false);
|
||||
return new ComponentFixture(comp, null !, false);
|
||||
}
|
||||
|
||||
describe('errors', () => {
|
||||
|
@ -291,7 +292,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
}
|
||||
|
||||
const ngModule = createModule(SomeModule);
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp).componentType)
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
|
||||
.toBe(SomeComp);
|
||||
expect(ngModule.injector.get(ComponentFactoryResolver)
|
||||
.resolveComponentFactory(SomeComp)
|
||||
|
@ -341,7 +342,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
}
|
||||
|
||||
const ngModule = createModule(SomeModule);
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp).componentType)
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
|
||||
.toBe(SomeComp);
|
||||
expect(ngModule.injector.get(ComponentFactoryResolver)
|
||||
.resolveComponentFactory(SomeComp)
|
||||
|
@ -359,7 +360,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
}
|
||||
|
||||
const ngModule = createModule(SomeModule);
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp).componentType)
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
|
||||
.toBe(SomeComp);
|
||||
expect(ngModule.injector.get(ComponentFactoryResolver)
|
||||
.resolveComponentFactory(SomeComp)
|
||||
|
@ -377,7 +378,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
}
|
||||
|
||||
const ngModule = createModule(SomeModule);
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp).componentType)
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
|
||||
.toBe(SomeComp);
|
||||
expect(ngModule.injector.get(ComponentFactoryResolver)
|
||||
.resolveComponentFactory(SomeComp)
|
||||
|
@ -394,7 +395,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
}
|
||||
|
||||
const ngModule = createModule(SomeModule);
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp).componentType)
|
||||
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
|
||||
.toBe(SomeComp);
|
||||
});
|
||||
|
||||
|
@ -605,7 +606,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
let moduleType: any = null;
|
||||
|
||||
|
||||
function createInjector(providers: Provider[], parent: Injector = null): Injector {
|
||||
function createInjector(providers: Provider[], parent?: Injector | null): Injector {
|
||||
@NgModule({providers: providers})
|
||||
class SomeModule {
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should support moving non projected light dom around', () => {
|
||||
let sourceDirective: ManualViewportDirective;
|
||||
let sourceDirective: ManualViewportDirective = undefined !;
|
||||
|
||||
@Directive({selector: '[manual]'})
|
||||
class ManualViewportDirective {
|
||||
|
|
|
@ -67,7 +67,7 @@ export function main() {
|
|||
'<needs-content-children #q><div text="foo"></div></needs-content-children>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
view.detectChanges();
|
||||
expect(q.textDirChildren.length).toEqual(1);
|
||||
expect(q.numberOfChildrenAfterContentInit).toEqual(1);
|
||||
|
@ -79,7 +79,7 @@ export function main() {
|
|||
const view = createTestCmp(MyComp0, template);
|
||||
view.componentInstance.shouldShow = true;
|
||||
view.detectChanges();
|
||||
const q: NeedsContentChild = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsContentChild = view.debugElement.children[0].references !['q'];
|
||||
expect(q.logs).toEqual([['setter', 'foo'], ['init', 'foo'], ['check', 'foo']]);
|
||||
|
||||
view.componentInstance.shouldShow = false;
|
||||
|
@ -93,7 +93,7 @@ export function main() {
|
|||
const template = '<needs-view-child #q></needs-view-child>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
|
||||
const q: NeedsViewChild = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewChild = view.debugElement.children[0].references !['q'];
|
||||
expect(q.logs).toEqual([['setter', 'foo'], ['init', 'foo'], ['check', 'foo']]);
|
||||
|
||||
q.shouldShow = false;
|
||||
|
@ -107,7 +107,7 @@ export function main() {
|
|||
const template =
|
||||
'<needs-static-content-view-child #q><div text="contentFoo"></div></needs-static-content-view-child>';
|
||||
const view = createTestCmp(MyComp0, template);
|
||||
const q: NeedsStaticContentAndViewChild = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsStaticContentAndViewChild = view.debugElement.children[0].references !['q'];
|
||||
expect(q.contentChild.text).toBeFalsy();
|
||||
expect(q.viewChild.text).toBeFalsy();
|
||||
|
||||
|
@ -128,7 +128,7 @@ export function main() {
|
|||
const view = TestBed.createComponent(MyComp0);
|
||||
|
||||
view.detectChanges();
|
||||
const q: NeedsViewChild = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewChild = view.debugElement.children[0].references !['q'];
|
||||
expect(q.logs).toEqual([['setter', 'foo'], ['init', 'foo'], ['check', 'foo']]);
|
||||
|
||||
q.shouldShow = false;
|
||||
|
@ -312,7 +312,7 @@ export function main() {
|
|||
'</needs-query>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
|
||||
q.query.changes.subscribe({
|
||||
next: () => {
|
||||
|
@ -333,14 +333,14 @@ export function main() {
|
|||
view.componentInstance.shouldShow = true;
|
||||
view.detectChanges();
|
||||
|
||||
const q: NeedsQuery = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsQuery = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query.length).toEqual(1);
|
||||
|
||||
view.componentInstance.shouldShow = false;
|
||||
view.detectChanges();
|
||||
view.componentInstance.shouldShow = true;
|
||||
view.detectChanges();
|
||||
const q2: NeedsQuery = view.debugElement.children[0].references['q'];
|
||||
const q2: NeedsQuery = view.debugElement.children[0].references !['q'];
|
||||
|
||||
expect(q2.query.length).toEqual(1);
|
||||
});
|
||||
|
@ -353,7 +353,7 @@ export function main() {
|
|||
'<div *ngFor="let item of list" [text]="item" #textLabel="textDir"></div>' +
|
||||
'</needs-query-by-ref-binding>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
|
||||
view.componentInstance.list = ['1d', '2d'];
|
||||
view.detectChanges();
|
||||
|
@ -367,7 +367,7 @@ export function main() {
|
|||
'<div text="two" #textLabel2="textDir"></div>' +
|
||||
'</needs-query-by-ref-bindings>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
|
||||
expect(q.query.first.text).toEqual('one');
|
||||
expect(q.query.last.text).toEqual('two');
|
||||
|
@ -378,7 +378,7 @@ export function main() {
|
|||
'<div *ngFor="let item of list" [text]="item" #textLabel="textDir"></div>' +
|
||||
'</needs-query-by-ref-binding>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
|
||||
view.componentInstance.list = ['1d', '2d'];
|
||||
view.detectChanges();
|
||||
|
@ -394,7 +394,7 @@ export function main() {
|
|||
'</div>' +
|
||||
'</needs-query-by-ref-binding>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
|
||||
view.componentInstance.list = ['1d', '2d'];
|
||||
view.detectChanges();
|
||||
|
@ -415,14 +415,14 @@ export function main() {
|
|||
const template = '<needs-view-query-by-ref-binding #q></needs-view-query-by-ref-binding>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
|
||||
const q: NeedsViewQueryByLabel = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewQueryByLabel = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query.first.nativeElement).toHaveText('text');
|
||||
});
|
||||
|
||||
it('should contain all child directives in the view dom', () => {
|
||||
const template = '<needs-view-children #q></needs-view-children>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
expect(q.textDirChildren.length).toEqual(1);
|
||||
expect(q.numberOfChildrenAfterViewInit).toEqual(1);
|
||||
});
|
||||
|
@ -432,21 +432,21 @@ export function main() {
|
|||
it('should contain all the elements in the view with that have the given directive', () => {
|
||||
const template = '<needs-view-query #q><div text="ignoreme"></div></needs-view-query>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQuery = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewQuery = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2', '3', '4']);
|
||||
});
|
||||
|
||||
it('should not include directive present on the host element', () => {
|
||||
const template = '<needs-view-query #q text="self"></needs-view-query>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQuery = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewQuery = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2', '3', '4']);
|
||||
});
|
||||
|
||||
it('should reflect changes in the component', () => {
|
||||
const template = '<needs-view-query-if #q></needs-view-query-if>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQueryIf = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewQueryIf = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query.length).toBe(0);
|
||||
|
||||
q.show = true;
|
||||
|
@ -458,7 +458,7 @@ export function main() {
|
|||
it('should not be affected by other changes in the component', () => {
|
||||
const template = '<needs-view-query-nested-if #q></needs-view-query-nested-if>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQueryNestedIf = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewQueryNestedIf = view.debugElement.children[0].references !['q'];
|
||||
|
||||
expect(q.query.length).toEqual(1);
|
||||
expect(q.query.first.text).toEqual('1');
|
||||
|
@ -473,7 +473,7 @@ export function main() {
|
|||
() => {
|
||||
const template = '<needs-view-query-order #q></needs-view-query-order>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQueryOrder = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewQueryOrder = view.debugElement.children[0].references !['q'];
|
||||
|
||||
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2', '3', '4']);
|
||||
|
||||
|
@ -486,7 +486,7 @@ export function main() {
|
|||
() => {
|
||||
const template = '<needs-view-query-order-with-p #q></needs-view-query-order-with-p>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQueryOrderWithParent = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewQueryOrderWithParent = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2', '3', '4']);
|
||||
|
||||
q.list = ['-3', '2'];
|
||||
|
@ -497,7 +497,7 @@ export function main() {
|
|||
it('should handle long ngFor cycles', () => {
|
||||
const template = '<needs-view-query-order #q></needs-view-query-order>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQueryOrder = view.debugElement.children[0].references['q'];
|
||||
const q: NeedsViewQueryOrder = view.debugElement.children[0].references !['q'];
|
||||
|
||||
// no significance to 50, just a reasonably large cycle.
|
||||
for (let i = 0; i < 50; i++) {
|
||||
|
@ -511,7 +511,7 @@ export function main() {
|
|||
it('should support more than three queries', () => {
|
||||
const template = '<needs-four-queries #q><div text="1"></div></needs-four-queries>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query1).toBeDefined();
|
||||
expect(q.query2).toBeDefined();
|
||||
expect(q.query3).toBeDefined();
|
||||
|
@ -524,7 +524,7 @@ export function main() {
|
|||
const template =
|
||||
'<manual-projecting #q><ng-template><div text="1"></div></ng-template></manual-projecting>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query.length).toBe(0);
|
||||
|
||||
q.create();
|
||||
|
@ -553,7 +553,7 @@ export function main() {
|
|||
'<auto-projecting #q><ng-template><div text="1"></div></ng-template></auto-projecting>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
|
||||
const q = view.debugElement.children[0].references['q'];
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
// This should be 1, but due to
|
||||
// https://github.com/angular/angular/issues/15117 this is 0.
|
||||
expect(q.query.length).toBe(0);
|
||||
|
@ -812,7 +812,7 @@ class NeedsViewContainerWithRead {
|
|||
|
||||
@Component({selector: 'has-null-query-condition', template: '<div></div>'})
|
||||
class HasNullQueryCondition {
|
||||
@ContentChildren(null) errorTrigger: any;
|
||||
@ContentChildren(null !) errorTrigger: any;
|
||||
}
|
||||
|
||||
@Component({selector: 'my-comp', template: ''})
|
||||
|
|
|
@ -75,7 +75,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
});
|
||||
|
||||
// should not throw for inputs starting with "on"
|
||||
let cmp: ComponentFixture<SecuredComponent>;
|
||||
let cmp: ComponentFixture<SecuredComponent> = undefined !;
|
||||
expect(() => cmp = TestBed.createComponent(SecuredComponent)).not.toThrow();
|
||||
|
||||
// must bind to the directive not to the property of the div
|
||||
|
|
|
@ -26,15 +26,15 @@ export function main() {
|
|||
});
|
||||
|
||||
function getErrorLoggerStack(e: Error): string {
|
||||
let logStack: string;
|
||||
getErrorLogger(e)(<any>{error: () => logStack = new Error().stack}, e.message);
|
||||
let logStack: string = undefined !;
|
||||
getErrorLogger(e)(<any>{error: () => logStack = new Error().stack !}, e.message);
|
||||
return logStack;
|
||||
}
|
||||
|
||||
function getSourceMap(genFile: string): SourceMap {
|
||||
const jitSources = jitSpy.calls.all().map((call) => call.args[call.args.length - 1]);
|
||||
return jitSources.map(source => extractSourceMap(source))
|
||||
.find(map => map && map.file === genFile);
|
||||
.find(map => !!(map && map.file === genFile)) !;
|
||||
}
|
||||
|
||||
function getSourcePositionForStack(stack: string):
|
||||
|
@ -46,9 +46,9 @@ export function main() {
|
|||
.map(line => /\((.*\.ngfactory\.js):(\d+):(\d+)/.exec(line))
|
||||
.filter(match => !!match)
|
||||
.map(match => ({
|
||||
file: match[1],
|
||||
line: parseInt(match[2], 10),
|
||||
column: parseInt(match[3], 10)
|
||||
file: match ![1],
|
||||
line: parseInt(match ![2], 10),
|
||||
column: parseInt(match ![3], 10)
|
||||
}));
|
||||
const ngFactoryLocation = ngFactoryLocations[0];
|
||||
|
||||
|
|
|
@ -184,19 +184,19 @@ class TestComp {
|
|||
|
||||
export function main() {
|
||||
function createComponentFixture<T>(
|
||||
template: string, providers: Provider[] = null, comp: Type<T> = null): ComponentFixture<T> {
|
||||
template: string, providers?: Provider[] | null, comp?: Type<T>): ComponentFixture<T> {
|
||||
if (!comp) {
|
||||
comp = <any>TestComp;
|
||||
}
|
||||
TestBed.overrideComponent(comp, {set: {template}});
|
||||
TestBed.overrideComponent(comp !, {set: {template}});
|
||||
if (providers && providers.length) {
|
||||
TestBed.overrideComponent(comp, {add: {providers: providers}});
|
||||
TestBed.overrideComponent(comp !, {add: {providers: providers}});
|
||||
}
|
||||
return TestBed.createComponent(comp);
|
||||
return TestBed.createComponent(comp !);
|
||||
}
|
||||
|
||||
function createComponent(
|
||||
template: string, providers: Provider[] = null, comp: Type<any> = null): DebugElement {
|
||||
template: string, providers?: Provider[], comp?: Type<any>): DebugElement {
|
||||
const fixture = createComponentFixture(template, providers, comp);
|
||||
fixture.detectChanges();
|
||||
return fixture.debugElement;
|
||||
|
|
|
@ -205,7 +205,7 @@ export function main() {
|
|||
expect(reflector.annotations(NoDecorators)).toEqual([]);
|
||||
expect(reflector.annotations(<any>{})).toEqual([]);
|
||||
expect(reflector.annotations(<any>1)).toEqual([]);
|
||||
expect(reflector.annotations(null)).toEqual([]);
|
||||
expect(reflector.annotations(null !)).toEqual([]);
|
||||
});
|
||||
|
||||
it('should inherit parameters', () => {
|
||||
|
@ -226,11 +226,11 @@ export function main() {
|
|||
// as otherwise TS won't capture the ctor arguments!
|
||||
@ClassDecorator({value: 'child'})
|
||||
class ChildWithCtor extends Parent {
|
||||
constructor(@ParamDecorator('c') c: C) { super(null, null); }
|
||||
constructor(@ParamDecorator('c') c: C) { super(null !, null !); }
|
||||
}
|
||||
|
||||
class ChildWithCtorNoDecorator extends Parent {
|
||||
constructor(a: any, b: any, c: any) { super(null, null); }
|
||||
constructor(a: any, b: any, c: any) { super(null !, null !); }
|
||||
}
|
||||
|
||||
class NoDecorators {}
|
||||
|
@ -255,7 +255,7 @@ export function main() {
|
|||
expect(reflector.parameters(NoDecorators)).toEqual([]);
|
||||
expect(reflector.parameters(<any>{})).toEqual([]);
|
||||
expect(reflector.parameters(<any>1)).toEqual([]);
|
||||
expect(reflector.parameters(null)).toEqual([]);
|
||||
expect(reflector.parameters(null !)).toEqual([]);
|
||||
});
|
||||
|
||||
it('should inherit property metadata', () => {
|
||||
|
@ -294,7 +294,7 @@ export function main() {
|
|||
expect(reflector.propMetadata(NoDecorators)).toEqual({});
|
||||
expect(reflector.propMetadata(<any>{})).toEqual({});
|
||||
expect(reflector.propMetadata(<any>1)).toEqual({});
|
||||
expect(reflector.propMetadata(null)).toEqual({});
|
||||
expect(reflector.propMetadata(null !)).toEqual({});
|
||||
});
|
||||
|
||||
it('should inherit lifecycle hooks', () => {
|
||||
|
|
|
@ -11,9 +11,9 @@ import {stringify} from '../src/util';
|
|||
export function main() {
|
||||
describe('stringify', () => {
|
||||
it('should return string undefined when toString returns undefined',
|
||||
() => expect(stringify({toString: (): string => undefined})).toBe('undefined'));
|
||||
() => expect(stringify({toString: (): any => undefined})).toBe('undefined'));
|
||||
|
||||
it('should return string null when toString returns null',
|
||||
() => expect(stringify({toString: (): string => null})).toBe('null'));
|
||||
() => expect(stringify({toString: (): any => null})).toBe('null'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -30,23 +30,23 @@ export function main() {
|
|||
describe('create', () => {
|
||||
it('should create anchor nodes without parents', () => {
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||
anchorDef(NodeFlags.None, null, null, 0)
|
||||
anchorDef(NodeFlags.None, null !, null !, 0)
|
||||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(1);
|
||||
});
|
||||
|
||||
it('should create views with multiple root anchor nodes', () => {
|
||||
const rootNodes =
|
||||
createAndGetRootNodes(compViewDef([
|
||||
anchorDef(NodeFlags.None, null, null, 0), anchorDef(NodeFlags.None, null, null, 0)
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||
anchorDef(NodeFlags.None, null !, null !, 0),
|
||||
anchorDef(NodeFlags.None, null !, null !, 0)
|
||||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(2);
|
||||
});
|
||||
|
||||
it('should create anchor nodes with parents', () => {
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
anchorDef(NodeFlags.None, null, null, 0),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
anchorDef(NodeFlags.None, null !, null !, 0),
|
||||
])).rootNodes;
|
||||
expect(getDOM().childNodes(rootNodes[0]).length).toBe(1);
|
||||
});
|
||||
|
@ -54,8 +54,8 @@ export function main() {
|
|||
it('should add debug information to the renderer', () => {
|
||||
const someContext = new Object();
|
||||
const {view, rootNodes} = createAndGetRootNodes(
|
||||
compViewDef([anchorDef(NodeFlags.None, null, null, 0)]), someContext);
|
||||
expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asElementData(view, 0).renderElement);
|
||||
compViewDef([anchorDef(NodeFlags.None, null !, null !, 0)]), someContext);
|
||||
expect(getDebugNode(rootNodes[0]) !.nativeNode).toBe(asElementData(view, 0).renderElement);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,34 +13,32 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
|||
import {createRootView, isBrowser, removeNodes} from './helper';
|
||||
|
||||
export function main() {
|
||||
describe(
|
||||
`Component Views`, () => {
|
||||
describe(`Component Views`, () => {
|
||||
function compViewDef(
|
||||
nodes: NodeDef[], updateDirectives?: ViewUpdateFn, updateRenderer?: ViewUpdateFn,
|
||||
viewFlags: ViewFlags = ViewFlags.None): ViewDefinition {
|
||||
return viewDef(viewFlags, nodes, updateDirectives, updateRenderer);
|
||||
}
|
||||
|
||||
function createAndGetRootNodes(viewDef: ViewDefinition):
|
||||
{rootNodes: any[], view: ViewData} {
|
||||
function createAndGetRootNodes(viewDef: ViewDefinition): {rootNodes: any[], view: ViewData} {
|
||||
const view = createRootView(viewDef);
|
||||
const rootNodes = rootRenderNodes(view);
|
||||
return {rootNodes, view};
|
||||
}
|
||||
|
||||
it('should create and attach component views', () => {
|
||||
let instance: AComp;
|
||||
let instance: AComp = undefined !;
|
||||
class AComp {
|
||||
constructor() { instance = this; }
|
||||
}
|
||||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
NodeFlags.None, null !, null !, 1, 'div', null !, null !, null !, null !,
|
||||
() => compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span'),
|
||||
])),
|
||||
directiveDef(NodeFlags.Component, null, 0, AComp, []),
|
||||
directiveDef(NodeFlags.Component, null !, 0, AComp, []),
|
||||
]));
|
||||
|
||||
const compView = asElementData(view, 0).componentView;
|
||||
|
@ -64,7 +62,7 @@ export function main() {
|
|||
it('should select root elements based on a selector', () => {
|
||||
const view = createRootView(
|
||||
compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'div'),
|
||||
]),
|
||||
{}, [], 'root');
|
||||
const rootNodes = rootRenderNodes(view);
|
||||
|
@ -74,7 +72,7 @@ export function main() {
|
|||
it('should select root elements based on a node', () => {
|
||||
const view = createRootView(
|
||||
compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'div'),
|
||||
]),
|
||||
{}, [], rootNode);
|
||||
const rootNodes = rootRenderNodes(view);
|
||||
|
@ -84,7 +82,7 @@ export function main() {
|
|||
it('should set attributes on the root node', () => {
|
||||
const view = createRootView(
|
||||
compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'div', [['a', 'b']]),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'div', [['a', 'b']]),
|
||||
]),
|
||||
{}, [], rootNode);
|
||||
expect(rootNode.getAttribute('a')).toBe('b');
|
||||
|
@ -94,7 +92,7 @@ export function main() {
|
|||
rootNode.appendChild(document.createElement('div'));
|
||||
const view = createRootView(
|
||||
compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'div', [['a', 'b']]),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'div', [['a', 'b']]),
|
||||
]),
|
||||
{}, [], rootNode);
|
||||
expect(rootNode.childNodes.length).toBe(0);
|
||||
|
@ -102,28 +100,26 @@ export function main() {
|
|||
});
|
||||
}
|
||||
|
||||
describe(
|
||||
'data binding', () => {
|
||||
it('should dirty check component views',
|
||||
() => {
|
||||
describe('data binding', () => {
|
||||
it('should dirty check component views', () => {
|
||||
let value: any;
|
||||
class AComp {
|
||||
a: any;
|
||||
}
|
||||
|
||||
const update = jasmine.createSpy('updater').and.callFake(
|
||||
(check: NodeCheckFn, view: ViewData) => {
|
||||
const update =
|
||||
jasmine.createSpy('updater').and.callFake((check: NodeCheckFn, view: ViewData) => {
|
||||
check(view, 0, ArgumentType.Inline, value);
|
||||
});
|
||||
|
||||
const {view, rootNodes} = createAndGetRootNodes(
|
||||
compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div', null, null, null, null, () => compViewDef(
|
||||
elementDef(NodeFlags.None, null!, null!, 1, 'div', null!, null!, null!, null!, () => compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span', null, [[BindingFlags.TypeElementAttribute, 'a', SecurityContext.NONE]]),
|
||||
], null, update
|
||||
elementDef(NodeFlags.None, null!, null!, 0, 'span', null!, [[BindingFlags.TypeElementAttribute, 'a', SecurityContext.NONE]]),
|
||||
], null!, update
|
||||
)),
|
||||
directiveDef(NodeFlags.Component, null, 0, AComp, []),
|
||||
directiveDef(NodeFlags.Component, null!, 0, AComp, []),
|
||||
]));
|
||||
const compView = asElementData(view, 0).componentView;
|
||||
|
||||
|
@ -143,8 +139,7 @@ export function main() {
|
|||
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'v1'. Current value: 'v2'.`);
|
||||
});
|
||||
|
||||
it('should support detaching and attaching component views for dirty checking',
|
||||
() => {
|
||||
it('should support detaching and attaching component views for dirty checking', () => {
|
||||
class AComp {
|
||||
a: any;
|
||||
}
|
||||
|
@ -153,13 +148,13 @@ export function main() {
|
|||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
NodeFlags.None, null !, null !, 1, 'div', null !, null !, null !, null !,
|
||||
() => compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span'),
|
||||
],
|
||||
update)),
|
||||
directiveDef(NodeFlags.Component, null, 0, AComp, [], null, null),
|
||||
directiveDef(NodeFlags.Component, null !, 0, AComp, [], null !, null !),
|
||||
]));
|
||||
|
||||
const compView = asElementData(view, 0).componentView;
|
||||
|
@ -185,23 +180,22 @@ export function main() {
|
|||
|
||||
const update = jasmine.createSpy('updater');
|
||||
|
||||
const addListenerSpy =
|
||||
spyOn(HTMLElement.prototype, 'addEventListener').and.callThrough();
|
||||
const addListenerSpy = spyOn(HTMLElement.prototype, 'addEventListener').and.callThrough();
|
||||
|
||||
const {view} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
NodeFlags.None, null !, null !, 1, 'div', null !, null !, null !, null !,
|
||||
() => {
|
||||
return compViewDef(
|
||||
[
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 0, 'span', null, null,
|
||||
[[null, 'click']]),
|
||||
NodeFlags.None, null !, null !, 0, 'span', null !, null !,
|
||||
[[null !, 'click']]),
|
||||
],
|
||||
update, null, ViewFlags.OnPush);
|
||||
update, null !, ViewFlags.OnPush);
|
||||
}),
|
||||
directiveDef(NodeFlags.Component, null, 0, AComp, [], {a: [0, 'a']}),
|
||||
directiveDef(NodeFlags.Component, null !, 0, AComp, [], {a: [0, 'a']}),
|
||||
],
|
||||
(check, view) => { check(view, 1, ArgumentType.Inline, compInputValue); }));
|
||||
|
||||
|
@ -236,8 +230,7 @@ export function main() {
|
|||
});
|
||||
}
|
||||
|
||||
it('should stop dirty checking views that threw errors in change detection',
|
||||
() => {
|
||||
it('should stop dirty checking views that threw errors in change detection', () => {
|
||||
class AComp {
|
||||
a: any;
|
||||
}
|
||||
|
@ -245,20 +238,19 @@ export function main() {
|
|||
const update = jasmine.createSpy('updater');
|
||||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div', null, null, null, null, () => compViewDef(
|
||||
elementDef(NodeFlags.None, null!, null!, 1, 'div', null!, null!, null!, null!, () => compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span', null, [[BindingFlags.TypeElementAttribute, 'a', SecurityContext.NONE]]),
|
||||
elementDef(NodeFlags.None, null!, null!, 0, 'span', null!, [[BindingFlags.TypeElementAttribute, 'a', SecurityContext.NONE]]),
|
||||
],
|
||||
null, update)),
|
||||
null!, update)),
|
||||
directiveDef(
|
||||
NodeFlags.Component, null, 0, AComp, [], null, null,
|
||||
NodeFlags.Component, null!, 0, AComp, [], null!, null!,
|
||||
),
|
||||
]));
|
||||
|
||||
const compView = asElementData(view, 0).componentView;
|
||||
|
||||
update.and.callFake(
|
||||
(check: NodeCheckFn, view: ViewData) => { throw new Error('Test'); });
|
||||
update.and.callFake((check: NodeCheckFn, view: ViewData) => { throw new Error('Test'); });
|
||||
expect(() => Services.checkAndUpdateView(view)).toThrowError('Test');
|
||||
expect(update).toHaveBeenCalled();
|
||||
|
||||
|
@ -281,12 +273,12 @@ export function main() {
|
|||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
NodeFlags.None, null !, null !, 1, 'div', null !, null !, null !, null !,
|
||||
() => compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.OnDestroy, null, 0, ChildProvider, [])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.OnDestroy, null !, 0, ChildProvider, [])
|
||||
])),
|
||||
directiveDef(NodeFlags.Component, null, 0, AComp, [], null, null, ),
|
||||
directiveDef(NodeFlags.Component, null !, 0, AComp, [], null !, null !, ),
|
||||
]));
|
||||
|
||||
Services.destroyView(view);
|
||||
|
@ -297,7 +289,7 @@ export function main() {
|
|||
it('should throw on dirty checking destroyed views', () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 0, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'div'),
|
||||
],
|
||||
(view) => {}));
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ export function main() {
|
|||
describe('create', () => {
|
||||
it('should create elements without parents', () => {
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span')
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span')
|
||||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(1);
|
||||
expect(getDOM().nodeName(rootNodes[0]).toLowerCase()).toBe('span');
|
||||
|
@ -39,16 +39,16 @@ export function main() {
|
|||
|
||||
it('should create views with multiple root elements', () => {
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span'),
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span')
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span')
|
||||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(2);
|
||||
});
|
||||
|
||||
it('should create elements with parents', () => {
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span'),
|
||||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(1);
|
||||
const spanEl = getDOM().childNodes(rootNodes[0])[0];
|
||||
|
@ -57,7 +57,7 @@ export function main() {
|
|||
|
||||
it('should set fixed attributes', () => {
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'div', [['title', 'a']]),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'div', [['title', 'a']]),
|
||||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(1);
|
||||
expect(getDOM().getAttribute(rootNodes[0], 'title')).toBe('a');
|
||||
|
@ -66,8 +66,8 @@ export function main() {
|
|||
it('should add debug information to the renderer', () => {
|
||||
const someContext = new Object();
|
||||
const {view, rootNodes} = createAndGetRootNodes(
|
||||
compViewDef([elementDef(NodeFlags.None, null, null, 0, 'div')]), someContext);
|
||||
expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asElementData(view, 0).renderElement);
|
||||
compViewDef([elementDef(NodeFlags.None, null !, null !, 0, 'div')]), someContext);
|
||||
expect(getDebugNode(rootNodes[0]) !.nativeNode).toBe(asElementData(view, 0).renderElement);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -78,13 +78,13 @@ export function main() {
|
|||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 0, 'input', null,
|
||||
NodeFlags.None, null !, null !, 0, 'input', null !,
|
||||
[
|
||||
[BindingFlags.TypeProperty, 'title', SecurityContext.NONE],
|
||||
[BindingFlags.TypeProperty, 'value', SecurityContext.NONE]
|
||||
]),
|
||||
],
|
||||
null, (check, view) => {
|
||||
null !, (check, view) => {
|
||||
checkNodeInlineOrDynamic(check, view, 0, inlineDynamic, ['v1', 'v2']);
|
||||
}));
|
||||
|
||||
|
@ -103,13 +103,13 @@ export function main() {
|
|||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 0, 'div', null,
|
||||
NodeFlags.None, null !, null !, 0, 'div', null !,
|
||||
[
|
||||
[BindingFlags.TypeElementAttribute, 'a1', SecurityContext.NONE],
|
||||
[BindingFlags.TypeElementAttribute, 'a2', SecurityContext.NONE]
|
||||
]),
|
||||
],
|
||||
null, (check, view) => {
|
||||
null !, (check, view) => {
|
||||
checkNodeInlineOrDynamic(check, view, 0, inlineDynamic, ['v1', 'v2']);
|
||||
}));
|
||||
|
||||
|
@ -128,10 +128,10 @@ export function main() {
|
|||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 0, 'div', null,
|
||||
NodeFlags.None, null !, null !, 0, 'div', null !,
|
||||
[
|
||||
[BindingFlags.TypeElementClass, 'c1', null],
|
||||
[BindingFlags.TypeElementClass, 'c2', null]
|
||||
[BindingFlags.TypeElementClass, 'c1', null !],
|
||||
[BindingFlags.TypeElementClass, 'c2', null !]
|
||||
]),
|
||||
],
|
||||
(check, view) => {
|
||||
|
@ -153,13 +153,13 @@ export function main() {
|
|||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 0, 'div', null,
|
||||
NodeFlags.None, null !, null !, 0, 'div', null !,
|
||||
[
|
||||
[BindingFlags.TypeElementStyle, 'width', 'px'],
|
||||
[BindingFlags.TypeElementStyle, 'color', null]
|
||||
[BindingFlags.TypeElementStyle, 'color', null !]
|
||||
]),
|
||||
],
|
||||
null, (check, view) => {
|
||||
null !, (check, view) => {
|
||||
checkNodeInlineOrDynamic(check, view, 0, inlineDynamic, [10, 'red']);
|
||||
}));
|
||||
|
||||
|
@ -191,7 +191,7 @@ export function main() {
|
|||
const removeListenerSpy =
|
||||
spyOn(HTMLElement.prototype, 'removeEventListener').and.callThrough();
|
||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef([elementDef(
|
||||
NodeFlags.None, null, null, 0, 'button', null, null, [[null, 'click']],
|
||||
NodeFlags.None, null !, null !, 0, 'button', null !, null !, [[null !, 'click']],
|
||||
handleEventSpy)]));
|
||||
|
||||
rootNodes[0].click();
|
||||
|
@ -212,8 +212,8 @@ export function main() {
|
|||
const addListenerSpy = spyOn(window, 'addEventListener');
|
||||
const removeListenerSpy = spyOn(window, 'removeEventListener');
|
||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef([elementDef(
|
||||
NodeFlags.None, null, null, 0, 'button', null, null, [['window', 'windowClick']],
|
||||
handleEventSpy)]));
|
||||
NodeFlags.None, null !, null !, 0, 'button', null !, null !,
|
||||
[['window', 'windowClick']], handleEventSpy)]));
|
||||
|
||||
expect(addListenerSpy).toHaveBeenCalled();
|
||||
expect(addListenerSpy.calls.mostRecent().args[0]).toBe('windowClick');
|
||||
|
@ -235,8 +235,8 @@ export function main() {
|
|||
const addListenerSpy = spyOn(document, 'addEventListener');
|
||||
const removeListenerSpy = spyOn(document, 'removeEventListener');
|
||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef([elementDef(
|
||||
NodeFlags.None, null, null, 0, 'button', null, null, [['document', 'documentClick']],
|
||||
handleEventSpy)]));
|
||||
NodeFlags.None, null !, null !, 0, 'button', null !, null !,
|
||||
[['document', 'documentClick']], handleEventSpy)]));
|
||||
|
||||
expect(addListenerSpy).toHaveBeenCalled();
|
||||
expect(addListenerSpy.calls.mostRecent().args[0]).toBe('documentClick');
|
||||
|
@ -255,10 +255,10 @@ export function main() {
|
|||
|
||||
it('should preventDefault only if the handler returns false', () => {
|
||||
let eventHandlerResult: any;
|
||||
let preventDefaultSpy: jasmine.Spy;
|
||||
let preventDefaultSpy: jasmine.Spy = undefined !;
|
||||
|
||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef([elementDef(
|
||||
NodeFlags.None, null, null, 0, 'button', null, null, [[null, 'click']],
|
||||
NodeFlags.None, null !, null !, 0, 'button', null !, null !, [[null !, 'click']],
|
||||
(view, eventName, event) => {
|
||||
preventDefaultSpy = spyOn(event, 'preventDefault').and.callThrough();
|
||||
return eventHandlerResult;
|
||||
|
@ -284,7 +284,7 @@ export function main() {
|
|||
it('should report debug info on event errors', () => {
|
||||
const addListenerSpy = spyOn(HTMLElement.prototype, 'addEventListener').and.callThrough();
|
||||
const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef([elementDef(
|
||||
NodeFlags.None, null, null, 0, 'button', null, null, [[null, 'click']],
|
||||
NodeFlags.None, null !, null !, 0, 'button', null !, null !, [[null !, 'click']],
|
||||
() => { throw new Error('Test'); })]));
|
||||
|
||||
let err: any;
|
||||
|
|
|
@ -38,10 +38,10 @@ export function main() {
|
|||
|
||||
const {view: parentView} = createAndGetRootNodes(
|
||||
compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
anchorDef(
|
||||
NodeFlags.EmbeddedViews, null, null, 0, null,
|
||||
embeddedViewDef([elementDef(NodeFlags.None, null, null, 0, 'span')])),
|
||||
NodeFlags.EmbeddedViews, null !, null !, 0, null !,
|
||||
embeddedViewDef([elementDef(NodeFlags.None, null !, null !, 0, 'span')])),
|
||||
]),
|
||||
parentContext);
|
||||
|
||||
|
@ -53,13 +53,14 @@ export function main() {
|
|||
|
||||
it('should attach and detach embedded views', () => {
|
||||
const {view: parentView, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 2, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 0, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span', [['name', 'child0']])
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 0, null !, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span', [['name', 'child0']])
|
||||
])),
|
||||
anchorDef(NodeFlags.None, null, null, 0, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span', [['name', 'child1']])
|
||||
]))
|
||||
anchorDef(
|
||||
NodeFlags.None, null !, null !, 0, null !,
|
||||
embeddedViewDef(
|
||||
[elementDef(NodeFlags.None, null !, null !, 0, 'span', [['name', 'child1']])]))
|
||||
]));
|
||||
const viewContainerData = asElementData(parentView, 1);
|
||||
|
||||
|
@ -83,13 +84,14 @@ export function main() {
|
|||
|
||||
it('should move embedded views', () => {
|
||||
const {view: parentView, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 2, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 0, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span', [['name', 'child0']])
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 0, null !, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span', [['name', 'child0']])
|
||||
])),
|
||||
anchorDef(NodeFlags.None, null, null, 0, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span', [['name', 'child1']])
|
||||
]))
|
||||
anchorDef(
|
||||
NodeFlags.None, null !, null !, 0, null !,
|
||||
embeddedViewDef(
|
||||
[elementDef(NodeFlags.None, null !, null !, 0, 'span', [['name', 'child1']])]))
|
||||
]));
|
||||
const viewContainerData = asElementData(parentView, 1);
|
||||
|
||||
|
@ -101,7 +103,7 @@ export function main() {
|
|||
|
||||
moveEmbeddedView(viewContainerData, 0, 1);
|
||||
|
||||
expect(viewContainerData.viewContainer._embeddedViews).toEqual([childView1, childView0]);
|
||||
expect(viewContainerData.viewContainer !._embeddedViews).toEqual([childView1, childView0]);
|
||||
// 2 anchors + 2 elements
|
||||
const rootChildren = getDOM().childNodes(rootNodes[0]);
|
||||
expect(rootChildren.length).toBe(4);
|
||||
|
@ -111,10 +113,10 @@ export function main() {
|
|||
|
||||
it('should include embedded views in root nodes', () => {
|
||||
const {view: parentView} = createAndGetRootNodes(compViewDef([
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 0, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span', [['name', 'child0']])
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 0, null !, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span', [['name', 'child0']])
|
||||
])),
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span', [['name', 'after']])
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span', [['name', 'after']])
|
||||
]));
|
||||
|
||||
const childView0 = Services.createEmbeddedView(parentView, parentView.def.nodes[0]);
|
||||
|
@ -134,12 +136,12 @@ export function main() {
|
|||
});
|
||||
|
||||
const {view: parentView, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
anchorDef(
|
||||
NodeFlags.EmbeddedViews, null, null, 0, null,
|
||||
NodeFlags.EmbeddedViews, null !, null !, 0, null !,
|
||||
embeddedViewDef(
|
||||
[elementDef(
|
||||
NodeFlags.None, null, null, 0, 'span', null,
|
||||
NodeFlags.None, null !, null !, 0, 'span', null !,
|
||||
[[BindingFlags.TypeElementAttribute, 'name', SecurityContext.NONE]])],
|
||||
update))
|
||||
]));
|
||||
|
@ -171,10 +173,10 @@ export function main() {
|
|||
}
|
||||
|
||||
const {view: parentView} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 0, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.OnDestroy, null, 0, ChildProvider, [])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 0, null !, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.OnDestroy, null !, 0, ChildProvider, [])
|
||||
]))
|
||||
]));
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ export function main() {
|
|||
|
||||
return [
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1 + contentNodes.length, 'acomp', null, null, null, null,
|
||||
() => aCompViewDef),
|
||||
directiveDef(NodeFlags.Component, null, 0, AComp, []), ...contentNodes
|
||||
NodeFlags.None, null !, null !, 1 + contentNodes.length, 'acomp', null !, null !,
|
||||
null !, null !, () => aCompViewDef),
|
||||
directiveDef(NodeFlags.Component, null !, 0, AComp, []), ...contentNodes
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -46,14 +46,15 @@ export function main() {
|
|||
|
||||
it('should create ng-content nodes without parents', () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(
|
||||
compViewDef(hostElDef([textDef(0, ['a'])], [ngContentDef(null, 0)])));
|
||||
compViewDef(hostElDef([textDef(0, ['a'])], [ngContentDef(null !, 0)])));
|
||||
|
||||
expect(getDOM().firstChild(rootNodes[0])).toBe(asTextData(view, 2).renderText);
|
||||
});
|
||||
|
||||
it('should create views with multiple root ng-content nodes', () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef(
|
||||
[textDef(0, ['a']), textDef(1, ['b'])], [ngContentDef(null, 0), ngContentDef(null, 1)])));
|
||||
[textDef(0, ['a']), textDef(1, ['b'])],
|
||||
[ngContentDef(null !, 0), ngContentDef(null !, 1)])));
|
||||
|
||||
expect(getDOM().childNodes(rootNodes[0])[0]).toBe(asTextData(view, 2).renderText);
|
||||
expect(getDOM().childNodes(rootNodes[0])[1]).toBe(asTextData(view, 3).renderText);
|
||||
|
@ -62,7 +63,7 @@ export function main() {
|
|||
it('should create ng-content nodes with parents', () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef(
|
||||
[textDef(0, ['a'])],
|
||||
[elementDef(NodeFlags.None, null, null, 1, 'div'), ngContentDef(null, 0)])));
|
||||
[elementDef(NodeFlags.None, null !, null !, 1, 'div'), ngContentDef(null !, 0)])));
|
||||
|
||||
expect(getDOM().firstChild(getDOM().firstChild(rootNodes[0])))
|
||||
.toBe(asTextData(view, 2).renderText);
|
||||
|
@ -71,7 +72,7 @@ export function main() {
|
|||
it('should reproject ng-content nodes', () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
hostElDef([textDef(0, ['a'])], hostElDef([ngContentDef(0, 0)], [
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'), ngContentDef(null, 0)
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'), ngContentDef(null !, 0)
|
||||
]))));
|
||||
expect(getDOM().firstChild(getDOM().firstChild(getDOM().firstChild(rootNodes[0]))))
|
||||
.toBe(asTextData(view, 2).renderText);
|
||||
|
@ -84,30 +85,38 @@ export function main() {
|
|||
}
|
||||
}
|
||||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef(
|
||||
const {view, rootNodes} =
|
||||
createAndGetRootNodes(
|
||||
compViewDef(
|
||||
hostElDef(
|
||||
[
|
||||
anchorDef(
|
||||
NodeFlags.EmbeddedViews, null, 0, 1, null, embeddedViewDef([textDef(null, ['a'])])),
|
||||
NodeFlags.EmbeddedViews, null !, 0, 1, null !,
|
||||
embeddedViewDef([textDef(null !, ['a'])])),
|
||||
directiveDef(
|
||||
NodeFlags.None, null, 0, CreateViewService, [TemplateRef, ViewContainerRef])
|
||||
NodeFlags.None, null !, 0, CreateViewService,
|
||||
[TemplateRef, ViewContainerRef])
|
||||
],
|
||||
[elementDef(NodeFlags.None, null, null, 1, 'div'), ngContentDef(null, 0)])));
|
||||
[
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
ngContentDef(null !, 0)
|
||||
])));
|
||||
|
||||
const anchor = asElementData(view, 2);
|
||||
expect((getDOM().childNodes(getDOM().firstChild(rootNodes[0]))[0]))
|
||||
.toBe(anchor.renderElement);
|
||||
const embeddedView = anchor.viewContainer._embeddedViews[0];
|
||||
const embeddedView = anchor.viewContainer !._embeddedViews[0];
|
||||
expect((getDOM().childNodes(getDOM().firstChild(rootNodes[0]))[1]))
|
||||
.toBe(asTextData(embeddedView, 0).renderText);
|
||||
});
|
||||
|
||||
it('should include projected nodes when attaching / detaching embedded views', () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef([textDef(0, ['a'])], [
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, 0, 0, null, embeddedViewDef([
|
||||
ngContentDef(null, 0),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, 0, 0, null !, embeddedViewDef([
|
||||
ngContentDef(null !, 0),
|
||||
// The anchor would be added by the compiler after the ngContent
|
||||
anchorDef(NodeFlags.None, null, null, 0),
|
||||
anchorDef(NodeFlags.None, null !, null !, 0),
|
||||
])),
|
||||
])));
|
||||
|
||||
|
@ -127,7 +136,7 @@ export function main() {
|
|||
it('should use root projectable nodes', () => {
|
||||
const projectableNodes = [[document.createTextNode('a')], [document.createTextNode('b')]];
|
||||
const view = createRootView(
|
||||
compViewDef(hostElDef([], [ngContentDef(null, 0), ngContentDef(null, 1)])), {},
|
||||
compViewDef(hostElDef([], [ngContentDef(null !, 0), ngContentDef(null !, 1)])), {},
|
||||
projectableNodes);
|
||||
const rootNodes = rootRenderNodes(view);
|
||||
|
||||
|
|
|
@ -39,29 +39,29 @@ export function main() {
|
|||
constructor(public dep: any) { instance = this; }
|
||||
}
|
||||
|
||||
beforeEach(() => { instance = null; });
|
||||
beforeEach(() => { instance = null !; });
|
||||
|
||||
it('should create providers eagerly', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [])
|
||||
]));
|
||||
|
||||
expect(instance instanceof SomeService).toBe(true);
|
||||
});
|
||||
|
||||
it('should create providers lazily', () => {
|
||||
let lazy: LazyService;
|
||||
let lazy: LazyService = undefined !;
|
||||
class LazyService {
|
||||
constructor() { lazy = this; }
|
||||
}
|
||||
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
providerDef(
|
||||
NodeFlags.TypeClassProvider | NodeFlags.LazyProvider, null, LazyService, LazyService,
|
||||
[]),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [Injector])
|
||||
NodeFlags.TypeClassProvider | NodeFlags.LazyProvider, null !, LazyService,
|
||||
LazyService, []),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [Injector])
|
||||
]));
|
||||
|
||||
expect(lazy).toBeUndefined();
|
||||
|
@ -71,9 +71,9 @@ export function main() {
|
|||
|
||||
it('should create value providers', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
providerDef(NodeFlags.TypeValueProvider, null, 'someToken', 'someValue', []),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, ['someToken']),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
providerDef(NodeFlags.TypeValueProvider, null !, 'someToken', 'someValue', []),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, ['someToken']),
|
||||
]));
|
||||
|
||||
expect(instance.dep).toBe('someValue');
|
||||
|
@ -83,9 +83,9 @@ export function main() {
|
|||
function someFactory() { return 'someValue'; }
|
||||
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
providerDef(NodeFlags.TypeFactoryProvider, null, 'someToken', someFactory, []),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, ['someToken']),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
providerDef(NodeFlags.TypeFactoryProvider, null !, 'someToken', someFactory, []),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, ['someToken']),
|
||||
]));
|
||||
|
||||
expect(instance.dep).toBe('someValue');
|
||||
|
@ -93,11 +93,12 @@ export function main() {
|
|||
|
||||
it('should create useExisting providers', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 3, 'span'),
|
||||
providerDef(NodeFlags.TypeValueProvider, null, 'someExistingToken', 'someValue', []),
|
||||
elementDef(NodeFlags.None, null !, null !, 3, 'span'),
|
||||
providerDef(NodeFlags.TypeValueProvider, null !, 'someExistingToken', 'someValue', []),
|
||||
providerDef(
|
||||
NodeFlags.TypeUseExistingProvider, null, 'someToken', null, ['someExistingToken']),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, ['someToken']),
|
||||
NodeFlags.TypeUseExistingProvider, null !, 'someToken', null !,
|
||||
['someExistingToken']),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, ['someToken']),
|
||||
]));
|
||||
|
||||
expect(instance.dep).toBe('someValue');
|
||||
|
@ -113,9 +114,9 @@ export function main() {
|
|||
createRootView(
|
||||
compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
() => compViewDef([textDef(null, ['a'])])),
|
||||
directiveDef(NodeFlags.Component, null, 0, SomeService, [])
|
||||
NodeFlags.None, null !, null !, 1, 'div', null !, null !, null !, null !,
|
||||
() => compViewDef([textDef(null !, ['a'])])),
|
||||
directiveDef(NodeFlags.Component, null !, 0, SomeService, [])
|
||||
]),
|
||||
TestBed.get(Injector), [], getDOM().createElement('div'));
|
||||
} catch (e) {
|
||||
|
@ -133,9 +134,9 @@ export function main() {
|
|||
|
||||
it('should inject deps from the same element', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, Dep, []),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, Dep, []),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [Dep])
|
||||
]));
|
||||
|
||||
expect(instance.dep instanceof Dep).toBeTruthy();
|
||||
|
@ -143,10 +144,10 @@ export function main() {
|
|||
|
||||
it('should inject deps from a parent element', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 3, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, Dep, []),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
||||
elementDef(NodeFlags.None, null !, null !, 3, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, Dep, []),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [Dep])
|
||||
]));
|
||||
|
||||
expect(instance.dep instanceof Dep).toBeTruthy();
|
||||
|
@ -154,10 +155,10 @@ export function main() {
|
|||
|
||||
it('should not inject deps from sibling root elements', () => {
|
||||
const nodes = [
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, Dep, []),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, Dep, []),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [Dep])
|
||||
];
|
||||
|
||||
// root elements
|
||||
|
@ -166,20 +167,20 @@ export function main() {
|
|||
|
||||
// non root elements
|
||||
expect(
|
||||
() => createAndGetRootNodes(
|
||||
compViewDef([elementDef(NodeFlags.None, null, null, 4, 'span')].concat(nodes))))
|
||||
() => createAndGetRootNodes(compViewDef(
|
||||
[elementDef(NodeFlags.None, null !, null !, 4, 'span')].concat(nodes))))
|
||||
.toThrowError('No provider for Dep!');
|
||||
});
|
||||
|
||||
it('should inject from a parent elment in a parent view', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
NodeFlags.None, null !, null !, 1, 'div', null !, null !, null !, null !,
|
||||
() => compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [Dep])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [Dep])
|
||||
])),
|
||||
directiveDef(NodeFlags.Component, null, 0, Dep, []),
|
||||
directiveDef(NodeFlags.Component, null !, 0, Dep, []),
|
||||
]));
|
||||
|
||||
expect(instance.dep instanceof Dep).toBeTruthy();
|
||||
|
@ -187,29 +188,29 @@ export function main() {
|
|||
|
||||
it('should throw for missing dependencies', () => {
|
||||
expect(() => createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, ['nonExistingDep'])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, ['nonExistingDep'])
|
||||
])))
|
||||
.toThrowError('No provider for nonExistingDep!');
|
||||
});
|
||||
|
||||
it('should use null for optional missing dependencies', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(
|
||||
NodeFlags.None, null, 0, SomeService, [[DepFlags.Optional, 'nonExistingDep']])
|
||||
NodeFlags.None, null !, 0, SomeService, [[DepFlags.Optional, 'nonExistingDep']])
|
||||
]));
|
||||
expect(instance.dep).toBe(null);
|
||||
});
|
||||
|
||||
it('should skip the current element when using SkipSelf', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 4, 'span'),
|
||||
providerDef(NodeFlags.TypeValueProvider, null, 'someToken', 'someParentValue', []),
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
providerDef(NodeFlags.TypeValueProvider, null, 'someToken', 'someValue', []),
|
||||
elementDef(NodeFlags.None, null !, null !, 4, 'span'),
|
||||
providerDef(NodeFlags.TypeValueProvider, null !, 'someToken', 'someParentValue', []),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
providerDef(NodeFlags.TypeValueProvider, null !, 'someToken', 'someValue', []),
|
||||
directiveDef(
|
||||
NodeFlags.None, null, 0, SomeService, [[DepFlags.SkipSelf, 'someToken']])
|
||||
NodeFlags.None, null !, 0, SomeService, [[DepFlags.SkipSelf, 'someToken']])
|
||||
]));
|
||||
expect(instance.dep).toBe('someParentValue');
|
||||
});
|
||||
|
@ -217,8 +218,8 @@ export function main() {
|
|||
it('should ask the root injector',
|
||||
withModule({providers: [{provide: 'rootDep', useValue: 'rootValue'}]}, () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, ['rootDep'])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, ['rootDep'])
|
||||
]));
|
||||
|
||||
expect(instance.dep).toBe('rootValue');
|
||||
|
@ -227,8 +228,8 @@ export function main() {
|
|||
describe('builtin tokens', () => {
|
||||
it('should inject ViewContainerRef', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 1),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [ViewContainerRef])
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 1),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [ViewContainerRef])
|
||||
]));
|
||||
|
||||
expect(instance.dep.createEmbeddedView).toBeTruthy();
|
||||
|
@ -236,9 +237,10 @@ export function main() {
|
|||
|
||||
it('should inject TemplateRef', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
anchorDef(NodeFlags.None, null, null, 1, null, embeddedViewDef([anchorDef(
|
||||
NodeFlags.None, null, null, 0)])),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [TemplateRef])
|
||||
anchorDef(
|
||||
NodeFlags.None, null !, null !, 1, null !,
|
||||
embeddedViewDef([anchorDef(NodeFlags.None, null !, null !, 0)])),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [TemplateRef])
|
||||
]));
|
||||
|
||||
expect(instance.dep.createEmbeddedView).toBeTruthy();
|
||||
|
@ -246,8 +248,8 @@ export function main() {
|
|||
|
||||
it('should inject ElementRef', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [ElementRef])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [ElementRef])
|
||||
]));
|
||||
|
||||
expect(instance.dep.nativeElement).toBe(asElementData(view, 0).renderElement);
|
||||
|
@ -255,8 +257,8 @@ export function main() {
|
|||
|
||||
it('should inject Injector', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [Injector])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [Injector])
|
||||
]));
|
||||
|
||||
expect(instance.dep.get(SomeService)).toBe(instance);
|
||||
|
@ -264,8 +266,8 @@ export function main() {
|
|||
|
||||
it('should inject ChangeDetectorRef for non component providers', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [ChangeDetectorRef])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, SomeService, [ChangeDetectorRef])
|
||||
]));
|
||||
|
||||
expect(instance.dep._view).toBe(view);
|
||||
|
@ -274,11 +276,11 @@ export function main() {
|
|||
it('should inject ChangeDetectorRef for component providers', () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
NodeFlags.None, null !, null !, 1, 'div', null !, null !, null !, null !,
|
||||
() => compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span'),
|
||||
])),
|
||||
directiveDef(NodeFlags.Component, null, 0, SomeService, [ChangeDetectorRef]),
|
||||
directiveDef(NodeFlags.Component, null !, 0, SomeService, [ChangeDetectorRef]),
|
||||
]));
|
||||
|
||||
const compView = asElementData(view, 0).componentView;
|
||||
|
@ -288,9 +290,9 @@ export function main() {
|
|||
it('should inject RendererV1', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'span', null, null, null, null,
|
||||
() => compViewDef([anchorDef(NodeFlags.None, null, null, 0)])),
|
||||
directiveDef(NodeFlags.Component, null, 0, SomeService, [Renderer])
|
||||
NodeFlags.None, null !, null !, 1, 'span', null !, null !, null !, null !,
|
||||
() => compViewDef([anchorDef(NodeFlags.None, null !, null !, 0)])),
|
||||
directiveDef(NodeFlags.Component, null !, 0, SomeService, [Renderer])
|
||||
]));
|
||||
|
||||
expect(instance.dep.createElement).toBeTruthy();
|
||||
|
@ -299,9 +301,9 @@ export function main() {
|
|||
it('should inject Renderer2', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'span', null, null, null, null,
|
||||
() => compViewDef([anchorDef(NodeFlags.None, null, null, 0)])),
|
||||
directiveDef(NodeFlags.Component, null, 0, SomeService, [Renderer2])
|
||||
NodeFlags.None, null !, null !, 1, 'span', null !, null !, null !, null !,
|
||||
() => compViewDef([anchorDef(NodeFlags.None, null !, null !, 0)])),
|
||||
directiveDef(NodeFlags.Component, null !, 0, SomeService, [Renderer2])
|
||||
]));
|
||||
|
||||
expect(instance.dep.createElement).toBeTruthy();
|
||||
|
@ -316,7 +318,7 @@ export function main() {
|
|||
|
||||
ARG_TYPE_VALUES.forEach((inlineDynamic) => {
|
||||
it(`should update via strategy ${inlineDynamic}`, () => {
|
||||
let instance: SomeService;
|
||||
let instance: SomeService = undefined !;
|
||||
|
||||
class SomeService {
|
||||
a: any;
|
||||
|
@ -326,8 +328,9 @@ export function main() {
|
|||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, SomeService, [], {a: [0, 'a'], b: [1, 'b']})
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(
|
||||
NodeFlags.None, null !, 0, SomeService, [], {a: [0, 'a'], b: [1, 'b']})
|
||||
],
|
||||
(check, view) => {
|
||||
checkNodeInlineOrDynamic(check, view, 1, inlineDynamic, ['v1', 'v2']);
|
||||
|
@ -364,9 +367,10 @@ export function main() {
|
|||
const subscribe = spyOn(emitter, 'subscribe').and.callThrough();
|
||||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span', null, null, null, handleEvent),
|
||||
elementDef(
|
||||
NodeFlags.None, null !, null !, 1, 'span', null !, null !, null !, handleEvent),
|
||||
directiveDef(
|
||||
NodeFlags.None, null, 0, SomeService, [], null, {emitter: 'someEventName'})
|
||||
NodeFlags.None, null !, 0, SomeService, [], null !, {emitter: 'someEventName'})
|
||||
]));
|
||||
|
||||
emitter.emit('someEventInstance');
|
||||
|
@ -385,10 +389,10 @@ export function main() {
|
|||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'span', null, null, null,
|
||||
NodeFlags.None, null !, null !, 1, 'span', null !, null !, null !,
|
||||
() => { throw new Error('Test'); }),
|
||||
directiveDef(
|
||||
NodeFlags.None, null, 0, SomeService, [], null, {emitter: 'someEventName'})
|
||||
NodeFlags.None, null !, 0, SomeService, [], null !, {emitter: 'someEventName'})
|
||||
]));
|
||||
|
||||
let err: any;
|
||||
|
@ -430,10 +434,10 @@ export function main() {
|
|||
NodeFlags.AfterViewChecked | NodeFlags.OnDestroy;
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 3, 'span'),
|
||||
directiveDef(allFlags, null, 0, SomeService, [], {a: [0, 'a']}),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(allFlags, null, 0, SomeService, [], {a: [0, 'a']})
|
||||
elementDef(NodeFlags.None, null !, null !, 3, 'span'),
|
||||
directiveDef(allFlags, null !, 0, SomeService, [], {a: [0, 'a']}),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(allFlags, null !, 0, SomeService, [], {a: [0, 'a']})
|
||||
],
|
||||
(check, view) => {
|
||||
check(view, 1, ArgumentType.Inline, 'someValue');
|
||||
|
@ -489,9 +493,9 @@ export function main() {
|
|||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(
|
||||
NodeFlags.OnChanges, null, 0, SomeService, [], {a: [0, 'nonMinifiedA']})
|
||||
NodeFlags.OnChanges, null !, 0, SomeService, [], {a: [0, 'nonMinifiedA']})
|
||||
],
|
||||
(check, view) => { check(view, 1, ArgumentType.Inline, currValue); }));
|
||||
|
||||
|
@ -510,8 +514,8 @@ export function main() {
|
|||
}
|
||||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null, 0, SomeService, [], {a: [0, 'a']}),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null !, 0, SomeService, [], {a: [0, 'a']}),
|
||||
]));
|
||||
|
||||
let err: any;
|
||||
|
@ -533,8 +537,8 @@ export function main() {
|
|||
}
|
||||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.OnDestroy, null, 0, SomeService, [], {a: [0, 'a']}),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.OnDestroy, null !, 0, SomeService, [], {a: [0, 'a']}),
|
||||
]));
|
||||
|
||||
let err: any;
|
||||
|
|
|
@ -38,8 +38,8 @@ export function main() {
|
|||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'), pureArrayDef(2),
|
||||
directiveDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'), pureArrayDef(2),
|
||||
directiveDef(NodeFlags.None, null !, 0, Service, [], {data: [0, 'data']})
|
||||
],
|
||||
(check, view) => {
|
||||
const pureValue = checkNodeInlineOrDynamic(check, view, 1, inlineDynamic, values);
|
||||
|
@ -75,8 +75,8 @@ export function main() {
|
|||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'), pureObjectDef(['a', 'b']),
|
||||
directiveDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'), pureObjectDef(['a', 'b']),
|
||||
directiveDef(NodeFlags.None, null !, 0, Service, [], {data: [0, 'data']})
|
||||
],
|
||||
(check, view) => {
|
||||
const pureValue = checkNodeInlineOrDynamic(check, view, 1, inlineDynamic, values);
|
||||
|
@ -115,9 +115,9 @@ export function main() {
|
|||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 3, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 3, 'span'),
|
||||
pipeDef(NodeFlags.None, SomePipe, []), purePipeDef(2),
|
||||
directiveDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
|
||||
directiveDef(NodeFlags.None, null !, 0, Service, [], {data: [0, 'data']})
|
||||
],
|
||||
(check, view) => {
|
||||
const pureValue = checkNodeInlineOrDynamic(
|
||||
|
|
|
@ -43,7 +43,7 @@ export function main() {
|
|||
|
||||
function contentQueryProviders() {
|
||||
return [
|
||||
directiveDef(NodeFlags.None, null, 1, QueryService, []),
|
||||
directiveDef(NodeFlags.None, null !, 1, QueryService, []),
|
||||
queryDef(
|
||||
NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
|
||||
{'a': QueryBindingType.All})
|
||||
|
@ -53,14 +53,14 @@ export function main() {
|
|||
function compViewQueryProviders(extraChildCount: number, nodes: NodeDef[]) {
|
||||
return [
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1 + extraChildCount, 'div', null, null, null, null,
|
||||
() => compViewDef([
|
||||
NodeFlags.None, null !, null !, 1 + extraChildCount, 'div', null !, null !, null !,
|
||||
null !, () => compViewDef([
|
||||
queryDef(
|
||||
NodeFlags.TypeViewQuery | NodeFlags.DynamicQuery, someQueryId,
|
||||
{'a': QueryBindingType.All}),
|
||||
...nodes
|
||||
])),
|
||||
directiveDef(NodeFlags.Component, null, 0, QueryService, [], null, null, ),
|
||||
directiveDef(NodeFlags.Component, null !, 0, QueryService, [], null !, null !, ),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -73,10 +73,10 @@ export function main() {
|
|||
|
||||
it('should query providers on the same element and child elements', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 5, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 5, 'div'),
|
||||
...contentQueryProviders(),
|
||||
aServiceProvider(),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
aServiceProvider(),
|
||||
]));
|
||||
|
||||
|
@ -93,11 +93,11 @@ export function main() {
|
|||
|
||||
it('should not query providers on sibling or parent elements', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 6, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 6, 'div'),
|
||||
aServiceProvider(),
|
||||
elementDef(NodeFlags.None, null, null, 2, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'div'),
|
||||
...contentQueryProviders(),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
aServiceProvider(),
|
||||
]));
|
||||
|
||||
|
@ -114,7 +114,7 @@ export function main() {
|
|||
...compViewQueryProviders(
|
||||
0,
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
aServiceProvider(),
|
||||
]),
|
||||
]));
|
||||
|
@ -132,7 +132,7 @@ export function main() {
|
|||
...compViewQueryProviders(
|
||||
1,
|
||||
[
|
||||
elementDef(NodeFlags.None, null, null, 0, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 0, 'span'),
|
||||
]),
|
||||
aServiceProvider(),
|
||||
]));
|
||||
|
@ -146,10 +146,10 @@ export function main() {
|
|||
describe('embedded views', () => {
|
||||
it('should query providers in embedded views', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 5, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 5, 'div'),
|
||||
...contentQueryProviders(),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 2, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 2, null !, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
aServiceProvider(),
|
||||
])),
|
||||
...contentQueryProviders(),
|
||||
|
@ -172,15 +172,15 @@ export function main() {
|
|||
|
||||
it('should query providers in embedded views only at the template declaration', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 3, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 3, 'div'),
|
||||
...contentQueryProviders(),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 0, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 0, null !, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
aServiceProvider(),
|
||||
])),
|
||||
elementDef(NodeFlags.None, null, null, 3, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 3, 'div'),
|
||||
...contentQueryProviders(),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 0),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 0),
|
||||
]));
|
||||
|
||||
const childView = Services.createEmbeddedView(view, view.def.nodes[3]);
|
||||
|
@ -201,10 +201,10 @@ export function main() {
|
|||
|
||||
it('should update content queries if embedded views are added or removed', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 3, 'div'),
|
||||
elementDef(NodeFlags.None, null !, null !, 3, 'div'),
|
||||
...contentQueryProviders(),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 0, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 0, null !, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
aServiceProvider(),
|
||||
])),
|
||||
]));
|
||||
|
@ -232,8 +232,8 @@ export function main() {
|
|||
...compViewQueryProviders(
|
||||
0,
|
||||
[
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 0, null, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
anchorDef(NodeFlags.EmbeddedViews, null !, null !, 0, null !, embeddedViewDef([
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
aServiceProvider(),
|
||||
])),
|
||||
]),
|
||||
|
@ -265,8 +265,8 @@ export function main() {
|
|||
}
|
||||
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 4, 'div'),
|
||||
directiveDef(NodeFlags.None, null, 1, QueryService, []),
|
||||
elementDef(NodeFlags.None, null !, null !, 4, 'div'),
|
||||
directiveDef(NodeFlags.None, null !, 1, QueryService, []),
|
||||
queryDef(
|
||||
NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
|
||||
{'a': QueryBindingType.All}),
|
||||
|
@ -290,8 +290,8 @@ export function main() {
|
|||
}
|
||||
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 4, 'div'),
|
||||
directiveDef(NodeFlags.None, null, 1, QueryService, []),
|
||||
elementDef(NodeFlags.None, null !, null !, 4, 'div'),
|
||||
directiveDef(NodeFlags.None, null !, 1, QueryService, []),
|
||||
queryDef(
|
||||
NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
|
||||
{'a': QueryBindingType.First}),
|
||||
|
@ -313,8 +313,8 @@ export function main() {
|
|||
}
|
||||
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, [[someQueryId, QueryValueType.ElementRef]], null, 2, 'div'),
|
||||
directiveDef(NodeFlags.None, null, 1, QueryService, []),
|
||||
elementDef(NodeFlags.None, [[someQueryId, QueryValueType.ElementRef]], null !, 2, 'div'),
|
||||
directiveDef(NodeFlags.None, null !, 1, QueryService, []),
|
||||
queryDef(
|
||||
NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
|
||||
{'a': QueryBindingType.First}),
|
||||
|
@ -333,9 +333,9 @@ export function main() {
|
|||
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
anchorDef(
|
||||
NodeFlags.None, [[someQueryId, QueryValueType.TemplateRef]], null, 2, null,
|
||||
embeddedViewDef([anchorDef(NodeFlags.None, null, null, 0)])),
|
||||
directiveDef(NodeFlags.None, null, 1, QueryService, []),
|
||||
NodeFlags.None, [[someQueryId, QueryValueType.TemplateRef]], null !, 2, null !,
|
||||
embeddedViewDef([anchorDef(NodeFlags.None, null !, null !, 0)])),
|
||||
directiveDef(NodeFlags.None, null !, 1, QueryService, []),
|
||||
queryDef(
|
||||
NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
|
||||
{'a': QueryBindingType.First}),
|
||||
|
@ -354,8 +354,8 @@ export function main() {
|
|||
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
anchorDef(
|
||||
NodeFlags.EmbeddedViews, [[someQueryId, QueryValueType.ViewContainerRef]], null, 2),
|
||||
directiveDef(NodeFlags.None, null, 1, QueryService, []),
|
||||
NodeFlags.EmbeddedViews, [[someQueryId, QueryValueType.ViewContainerRef]], null !, 2),
|
||||
directiveDef(NodeFlags.None, null !, 1, QueryService, []),
|
||||
queryDef(
|
||||
NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
|
||||
{'a': QueryBindingType.First}),
|
||||
|
@ -375,8 +375,8 @@ export function main() {
|
|||
}
|
||||
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 3, 'div'),
|
||||
directiveDef(NodeFlags.None, null, 1, QueryService, []),
|
||||
elementDef(NodeFlags.None, null !, null !, 3, 'div'),
|
||||
directiveDef(NodeFlags.None, null !, 1, QueryService, []),
|
||||
queryDef(
|
||||
NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
|
||||
{'a': QueryBindingType.All}),
|
||||
|
|
|
@ -36,12 +36,12 @@ export function main() {
|
|||
function createViewWithData() {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
NodeFlags.None, null !, null !, 1, 'div', null !, null !, null !, null !,
|
||||
() => compViewDef([
|
||||
elementDef(NodeFlags.None, [['ref', QueryValueType.ElementRef]], null, 2, 'span'),
|
||||
directiveDef(NodeFlags.None, null, 0, AService, []), textDef(null, ['a'])
|
||||
elementDef(NodeFlags.None, [['ref', QueryValueType.ElementRef]], null !, 2, 'span'),
|
||||
directiveDef(NodeFlags.None, null !, 0, AService, []), textDef(null !, ['a'])
|
||||
])),
|
||||
directiveDef(NodeFlags.Component, null, 0, AComp, []),
|
||||
directiveDef(NodeFlags.Component, null !, 0, AComp, []),
|
||||
]));
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -30,22 +30,22 @@ export function main() {
|
|||
|
||||
describe('create', () => {
|
||||
it('should create text nodes without parents', () => {
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([textDef(null, ['a'])])).rootNodes;
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([textDef(null !, ['a'])])).rootNodes;
|
||||
expect(rootNodes.length).toBe(1);
|
||||
expect(getDOM().getText(rootNodes[0])).toBe('a');
|
||||
});
|
||||
|
||||
it('should create views with multiple root text nodes', () => {
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||
textDef(null, ['a']), textDef(null, ['b'])
|
||||
textDef(null !, ['a']), textDef(null !, ['b'])
|
||||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(2);
|
||||
});
|
||||
|
||||
it('should create text nodes with parents', () => {
|
||||
const rootNodes = createAndGetRootNodes(compViewDef([
|
||||
elementDef(NodeFlags.None, null, null, 1, 'div'),
|
||||
textDef(null, ['a']),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'div'),
|
||||
textDef(null !, ['a']),
|
||||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(1);
|
||||
const textNode = getDOM().firstChild(rootNodes[0]);
|
||||
|
@ -55,8 +55,8 @@ export function main() {
|
|||
it('should add debug information to the renderer', () => {
|
||||
const someContext = new Object();
|
||||
const {view, rootNodes} =
|
||||
createAndGetRootNodes(compViewDef([textDef(null, ['a'])]), someContext);
|
||||
expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asTextData(view, 0).renderText);
|
||||
createAndGetRootNodes(compViewDef([textDef(null !, ['a'])]), someContext);
|
||||
expect(getDebugNode(rootNodes[0]) !.nativeNode).toBe(asTextData(view, 0).renderText);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -65,9 +65,9 @@ export function main() {
|
|||
it(`should update via strategy ${inlineDynamic}`, () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
textDef(null, ['0', '1', '2']),
|
||||
textDef(null !, ['0', '1', '2']),
|
||||
],
|
||||
null, (check, view) => {
|
||||
null !, (check, view) => {
|
||||
checkNodeInlineOrDynamic(check, view, 0, inlineDynamic, ['a', 'b']);
|
||||
}));
|
||||
|
||||
|
|
|
@ -13,15 +13,15 @@ export function main() {
|
|||
describe('viewDef', () => {
|
||||
|
||||
describe('parent', () => {
|
||||
function parents(viewDef: ViewDefinition): number[] {
|
||||
function parents(viewDef: ViewDefinition): (number | null)[] {
|
||||
return viewDef.nodes.map(node => node.parent ? node.parent.index : null);
|
||||
}
|
||||
|
||||
it('should calculate parents for one level', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
textDef(null, ['a']),
|
||||
textDef(null, ['a']),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
textDef(null !, ['a']),
|
||||
textDef(null !, ['a']),
|
||||
]);
|
||||
|
||||
expect(parents(vd)).toEqual([null, 0, 0]);
|
||||
|
@ -29,11 +29,11 @@ export function main() {
|
|||
|
||||
it('should calculate parents for one level, multiple roots', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
textDef(null, ['a']),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
textDef(null, ['a']),
|
||||
textDef(null, ['a']),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
textDef(null !, ['a']),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
textDef(null !, ['a']),
|
||||
textDef(null !, ['a']),
|
||||
]);
|
||||
|
||||
expect(parents(vd)).toEqual([null, 0, null, 2, null]);
|
||||
|
@ -41,12 +41,12 @@ export function main() {
|
|||
|
||||
it('should calculate parents for multiple levels', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
textDef(null, ['a']),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
textDef(null, ['a']),
|
||||
textDef(null, ['a']),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
textDef(null !, ['a']),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
textDef(null !, ['a']),
|
||||
textDef(null !, ['a']),
|
||||
]);
|
||||
|
||||
expect(parents(vd)).toEqual([null, 0, 1, null, 3, null]);
|
||||
|
@ -65,8 +65,8 @@ export function main() {
|
|||
|
||||
it('should calculate childFlags for one level', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null, 0, AService, [])
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null !, 0, AService, [])
|
||||
]);
|
||||
|
||||
expect(childFlags(vd)).toEqual([
|
||||
|
@ -80,9 +80,9 @@ export function main() {
|
|||
|
||||
it('should calculate childFlags for two levels', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null, 0, AService, [])
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null !, 0, AService, [])
|
||||
]);
|
||||
|
||||
expect(childFlags(vd)).toEqual([
|
||||
|
@ -98,11 +98,11 @@ export function main() {
|
|||
|
||||
it('should calculate childFlags for one level, multiple roots', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null, 0, AService, []),
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentInit, null, 0, AService, []),
|
||||
directiveDef(NodeFlags.AfterViewChecked, null, 0, AService, []),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null !, 0, AService, []),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentInit, null !, 0, AService, []),
|
||||
directiveDef(NodeFlags.AfterViewChecked, null !, 0, AService, []),
|
||||
]);
|
||||
|
||||
expect(childFlags(vd)).toEqual([
|
||||
|
@ -120,12 +120,12 @@ export function main() {
|
|||
|
||||
it('should calculate childFlags for multiple levels', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null, 0, AService, []),
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentInit, null, 0, AService, []),
|
||||
directiveDef(NodeFlags.AfterViewInit, null, 0, AService, []),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentChecked, null !, 0, AService, []),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
directiveDef(NodeFlags.AfterContentInit, null !, 0, AService, []),
|
||||
directiveDef(NodeFlags.AfterViewInit, null !, 0, AService, []),
|
||||
]);
|
||||
|
||||
expect(childFlags(vd)).toEqual([
|
||||
|
@ -151,7 +151,7 @@ export function main() {
|
|||
|
||||
it('should calculate childMatchedQueries for one level', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, [[1, QueryValueType.Provider]], 0, AService, [])
|
||||
]);
|
||||
|
||||
|
@ -160,8 +160,8 @@ export function main() {
|
|||
|
||||
it('should calculate childMatchedQueries for two levels', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, [[1, QueryValueType.Provider]], 0, AService, [])
|
||||
]);
|
||||
|
||||
|
@ -170,9 +170,9 @@ export function main() {
|
|||
|
||||
it('should calculate childMatchedQueries for one level, multiple roots', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, [[1, QueryValueType.Provider]], 0, AService, []),
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
directiveDef(NodeFlags.None, [[2, QueryValueType.Provider]], 0, AService, []),
|
||||
directiveDef(NodeFlags.None, [[3, QueryValueType.Provider]], 0, AService, []),
|
||||
]);
|
||||
|
@ -184,10 +184,10 @@ export function main() {
|
|||
|
||||
it('should calculate childMatchedQueries for multiple levels', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
directiveDef(NodeFlags.None, [[1, QueryValueType.Provider]], 0, AService, []),
|
||||
elementDef(NodeFlags.None, null, null, 2, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
directiveDef(NodeFlags.None, [[2, QueryValueType.Provider]], 0, AService, []),
|
||||
directiveDef(NodeFlags.None, [[3, QueryValueType.Provider]], 0, AService, []),
|
||||
]);
|
||||
|
@ -199,13 +199,13 @@ export function main() {
|
|||
|
||||
it('should included embedded views into childMatchedQueries', () => {
|
||||
const vd = viewDef(ViewFlags.None, [
|
||||
elementDef(NodeFlags.None, null, null, 1, 'span'),
|
||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||
anchorDef(
|
||||
NodeFlags.None, null, null, 0, null,
|
||||
NodeFlags.None, null !, null !, 0, null !,
|
||||
() => viewDef(
|
||||
ViewFlags.None,
|
||||
[
|
||||
elementDef(NodeFlags.None, [[1, QueryValueType.Provider]], null, 0, 'span'),
|
||||
elementDef(NodeFlags.None, [[1, QueryValueType.Provider]], null !, 0, 'span'),
|
||||
]))
|
||||
]);
|
||||
|
||||
|
|
|
@ -468,12 +468,12 @@ function commonTests() {
|
|||
|
||||
it('should call onUnstable and onMicrotaskEmpty when an inner microtask is scheduled from outside angular',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
let resolve: (result: string) => void;
|
||||
let promise: Promise<string>;
|
||||
let resolve: (result: string | null) => void;
|
||||
let promise: Promise<string|null>;
|
||||
|
||||
macroTask(() => {
|
||||
NgZone.assertNotInAngularZone();
|
||||
promise = new Promise(res => { resolve = res; });
|
||||
promise = new Promise<string|null>(res => { resolve = res; });
|
||||
});
|
||||
|
||||
runNgZoneNoLog(() => {
|
||||
|
@ -637,15 +637,15 @@ function commonTests() {
|
|||
|
||||
it('should call onUnstable and onMicrotaskEmpty before and after each turn, respectively',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
let aResolve: (result: string) => void;
|
||||
let aResolve: (result: string | null) => void;
|
||||
let aPromise: Promise<string>;
|
||||
let bResolve: (result: string) => void;
|
||||
let bResolve: (result: string | null) => void;
|
||||
let bPromise: Promise<string>;
|
||||
|
||||
runNgZoneNoLog(() => {
|
||||
macroTask(() => {
|
||||
aPromise = new Promise(res => { aResolve = res; });
|
||||
bPromise = new Promise(res => { bResolve = res; });
|
||||
aPromise = new Promise<string|null>(res => { aResolve = res; });
|
||||
bPromise = new Promise<string|null>(res => { bResolve = res; });
|
||||
aPromise.then(_log.fn('a then'));
|
||||
bPromise.then(_log.fn('b then'));
|
||||
_log.add('run start');
|
||||
|
@ -763,7 +763,7 @@ function commonTests() {
|
|||
}));
|
||||
|
||||
it('should fakeAsync even if the NgZone was created outside.', fakeAsync(() => {
|
||||
let result: string = null;
|
||||
let result: string = null !;
|
||||
// try to escape the current fakeAsync zone by using NgZone which was created outside.
|
||||
ngZone.run(() => {
|
||||
Promise.resolve('works').then((v) => result = v);
|
||||
|
@ -776,7 +776,7 @@ function commonTests() {
|
|||
let asyncResult: string;
|
||||
const waitLongerThenTestFrameworkAsyncTimeout = 5;
|
||||
|
||||
beforeEach(() => { asyncResult = null; });
|
||||
beforeEach(() => { asyncResult = null !; });
|
||||
|
||||
it('should async even if the NgZone was created outside.', async(() => {
|
||||
// try to escape the current async zone by using NgZone which was created outside.
|
||||
|
|
|
@ -42,15 +42,16 @@ export class ComponentFixture<T> {
|
|||
|
||||
private _isStable: boolean = true;
|
||||
private _isDestroyed: boolean = false;
|
||||
private _resolve: (result: any) => void;
|
||||
private _promise: Promise<any> = null;
|
||||
private _resolve: ((result: any) => void)|null = null;
|
||||
private _promise: Promise<any>|null = null;
|
||||
private _onUnstableSubscription: any /** TODO #9100 */ = null;
|
||||
private _onStableSubscription: any /** TODO #9100 */ = null;
|
||||
private _onMicrotaskEmptySubscription: any /** TODO #9100 */ = null;
|
||||
private _onErrorSubscription: any /** TODO #9100 */ = null;
|
||||
|
||||
constructor(
|
||||
public componentRef: ComponentRef<T>, public ngZone: NgZone, private _autoDetect: boolean) {
|
||||
public componentRef: ComponentRef<T>, public ngZone: NgZone|null,
|
||||
private _autoDetect: boolean) {
|
||||
this.changeDetectorRef = componentRef.changeDetectorRef;
|
||||
this.elementRef = componentRef.location;
|
||||
this.debugElement = <DebugElement>getDebugNode(this.elementRef.nativeElement);
|
||||
|
@ -59,7 +60,7 @@ export class ComponentFixture<T> {
|
|||
this.componentRef = componentRef;
|
||||
this.ngZone = ngZone;
|
||||
|
||||
if (ngZone != null) {
|
||||
if (ngZone) {
|
||||
this._onUnstableSubscription =
|
||||
ngZone.onUnstable.subscribe({next: () => { this._isStable = false; }});
|
||||
this._onMicrotaskEmptySubscription = ngZone.onMicrotaskEmpty.subscribe({
|
||||
|
@ -82,7 +83,7 @@ export class ComponentFixture<T> {
|
|||
scheduleMicroTask(() => {
|
||||
if (!this.ngZone.hasPendingMacrotasks) {
|
||||
if (this._promise !== null) {
|
||||
this._resolve(true);
|
||||
this._resolve !(true);
|
||||
this._resolve = null;
|
||||
this._promise = null;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ export class TestBed implements Injector {
|
|||
}
|
||||
|
||||
static overrideTemplate(component: Type<any>, template: string): typeof TestBed {
|
||||
getTestBed().overrideComponent(component, {set: {template, templateUrl: null}});
|
||||
getTestBed().overrideComponent(component, {set: {template, templateUrl: null !}});
|
||||
return TestBed;
|
||||
}
|
||||
|
||||
|
@ -149,9 +149,9 @@ export class TestBed implements Injector {
|
|||
|
||||
private _instantiated: boolean = false;
|
||||
|
||||
private _compiler: TestingCompiler = null;
|
||||
private _moduleRef: NgModuleRef<any> = null;
|
||||
private _moduleWithComponentFactories: ModuleWithComponentFactories<any> = null;
|
||||
private _compiler: TestingCompiler = null !;
|
||||
private _moduleRef: NgModuleRef<any> = null !;
|
||||
private _moduleWithComponentFactories: ModuleWithComponentFactories<any> = null !;
|
||||
|
||||
private _compilerOptions: CompilerOptions[] = [];
|
||||
|
||||
|
@ -194,19 +194,19 @@ export class TestBed implements Injector {
|
|||
*/
|
||||
resetTestEnvironment() {
|
||||
this.resetTestingModule();
|
||||
this.platform = null;
|
||||
this.ngModule = null;
|
||||
this.platform = null !;
|
||||
this.ngModule = null !;
|
||||
}
|
||||
|
||||
resetTestingModule() {
|
||||
this._compiler = null;
|
||||
this._compiler = null !;
|
||||
this._moduleOverrides = [];
|
||||
this._componentOverrides = [];
|
||||
this._directiveOverrides = [];
|
||||
this._pipeOverrides = [];
|
||||
|
||||
this._moduleRef = null;
|
||||
this._moduleWithComponentFactories = null;
|
||||
this._moduleRef = null !;
|
||||
this._moduleWithComponentFactories = null !;
|
||||
this._compilerOptions = [];
|
||||
this._providers = [];
|
||||
this._declarations = [];
|
||||
|
@ -223,9 +223,9 @@ export class TestBed implements Injector {
|
|||
this._activeFixtures = [];
|
||||
}
|
||||
|
||||
platform: PlatformRef = null;
|
||||
platform: PlatformRef = null !;
|
||||
|
||||
ngModule: Type<any>|Type<any>[] = null;
|
||||
ngModule: Type<any>|Type<any>[] = null !;
|
||||
|
||||
configureCompiler(config: {providers?: any[], useJit?: boolean}) {
|
||||
this._assertNotInstantiated('TestBed.configureCompiler', 'configure the compiler');
|
||||
|
@ -383,7 +383,7 @@ export class TestBed implements Injector {
|
|||
}
|
||||
}
|
||||
|
||||
let _testBed: TestBed = null;
|
||||
let _testBed: TestBed = null !;
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
|
@ -463,7 +463,7 @@ export class InjectSetupWrapper {
|
|||
*/
|
||||
export function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
|
||||
export function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
|
||||
export function withModule(moduleDef: TestModuleMetadata, fn: Function = null): (() => any)|
|
||||
export function withModule(moduleDef: TestModuleMetadata, fn?: Function | null): (() => any)|
|
||||
InjectSetupWrapper {
|
||||
if (fn) {
|
||||
// Not using an arrow function to preserve context passed from call site
|
||||
|
|
|
@ -62,7 +62,7 @@ jsmBeforeEach(() => { testBed.resetTestingModule(); });
|
|||
|
||||
function _describe(jsmFn: Function, ...args: any[]) {
|
||||
const parentRunner = runnerStack.length === 0 ? null : runnerStack[runnerStack.length - 1];
|
||||
const runner = new BeforeEachRunner(parentRunner);
|
||||
const runner = new BeforeEachRunner(parentRunner !);
|
||||
runnerStack.push(runner);
|
||||
const suite = jsmFn(...args);
|
||||
runnerStack.pop();
|
||||
|
|
|
@ -20,9 +20,12 @@ export function html(html: string): Element {
|
|||
return div;
|
||||
}
|
||||
|
||||
export function multiTrim(text: string): string {
|
||||
export function multiTrim(text: string | null | undefined): string {
|
||||
if (typeof text == 'string') {
|
||||
return text.replace(/\n/g, '').replace(/\s\s+/g, ' ').trim();
|
||||
}
|
||||
throw new Error('Argument can not be undefined.');
|
||||
}
|
||||
|
||||
export function nodes(html: string) {
|
||||
const div = document.createElement('div');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/** @experimental */
|
||||
export declare function animate(timings: string | number, styles?: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata): AnimationAnimateMetadata;
|
||||
export declare function animate(timings: string | number, styles?: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | null): AnimationAnimateMetadata;
|
||||
|
||||
/** @experimental */
|
||||
export declare type AnimateTimings = {
|
||||
|
@ -10,7 +10,7 @@ export declare type AnimateTimings = {
|
|||
|
||||
/** @experimental */
|
||||
export interface AnimationAnimateMetadata extends AnimationMetadata {
|
||||
styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata;
|
||||
styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | null;
|
||||
timings: string | number | AnimateTimings;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ export declare function animate(timings: string | number, styles?: AnimationStyl
|
|||
|
||||
/** @deprecated */
|
||||
export interface AnimationAnimateMetadata extends AnimationMetadata {
|
||||
styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata;
|
||||
styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | null;
|
||||
timings: string | number | AnimateTimings;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ export interface ContentChildrenDecorator {
|
|||
export declare function createPlatform(injector: Injector): PlatformRef;
|
||||
|
||||
/** @experimental */
|
||||
export declare function createPlatformFactory(parentPlatformFactory: (extraProviders?: Provider[]) => PlatformRef, name: string, providers?: Provider[]): (extraProviders?: Provider[]) => PlatformRef;
|
||||
export declare function createPlatformFactory(parentPlatformFactory: ((extraProviders?: Provider[]) => PlatformRef) | null, name: string, providers?: Provider[]): (extraProviders?: Provider[]) => PlatformRef;
|
||||
|
||||
/** @stable */
|
||||
export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
|
||||
|
@ -297,7 +297,7 @@ export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
|
|||
/** @experimental */
|
||||
export declare class DebugElement extends DebugNode {
|
||||
attributes: {
|
||||
[key: string]: string;
|
||||
[key: string]: string | null;
|
||||
};
|
||||
childNodes: DebugNode[];
|
||||
readonly children: DebugElement[];
|
||||
|
@ -310,7 +310,7 @@ export declare class DebugElement extends DebugNode {
|
|||
[key: string]: any;
|
||||
};
|
||||
styles: {
|
||||
[key: string]: string;
|
||||
[key: string]: string | null;
|
||||
};
|
||||
constructor(nativeNode: any, parent: any, _debugContext: DebugContext);
|
||||
addChild(child: DebugNode): void;
|
||||
|
@ -330,13 +330,13 @@ export declare class DebugNode {
|
|||
readonly injector: Injector;
|
||||
listeners: EventListener[];
|
||||
nativeNode: any;
|
||||
parent: DebugElement;
|
||||
parent: DebugElement | null;
|
||||
readonly providerTokens: any[];
|
||||
readonly references: {
|
||||
[key: string]: any;
|
||||
};
|
||||
/** @deprecated */ readonly source: string;
|
||||
constructor(nativeNode: any, parent: DebugNode, _debugContext: DebugContext);
|
||||
constructor(nativeNode: any, parent: DebugNode | null, _debugContext: DebugContext);
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
|
@ -344,14 +344,14 @@ export declare class DefaultIterableDiffer<V> implements IterableDiffer<V>, Iter
|
|||
readonly collection: NgIterable<V>;
|
||||
readonly isDirty: boolean;
|
||||
readonly length: number;
|
||||
constructor(_trackByFn?: TrackByFunction<V>);
|
||||
constructor(trackByFn?: TrackByFunction<V>);
|
||||
check(collection: NgIterable<V>): boolean;
|
||||
diff(collection: NgIterable<V>): DefaultIterableDiffer<V>;
|
||||
diff(collection: NgIterable<V>): DefaultIterableDiffer<V> | null;
|
||||
forEachAddedItem(fn: (record: IterableChangeRecord_<V>) => void): void;
|
||||
forEachIdentityChange(fn: (record: IterableChangeRecord_<V>) => void): void;
|
||||
forEachItem(fn: (record: IterableChangeRecord_<V>) => void): void;
|
||||
forEachMovedItem(fn: (record: IterableChangeRecord_<V>) => void): void;
|
||||
forEachOperation(fn: (item: IterableChangeRecord_<V>, previousIndex: number, currentIndex: number) => void): void;
|
||||
forEachOperation(fn: (item: IterableChangeRecord<V>, previousIndex: number | null, currentIndex: number | null) => void): void;
|
||||
forEachPreviousItem(fn: (record: IterableChangeRecord_<V>) => void): void;
|
||||
forEachRemovedItem(fn: (record: IterableChangeRecord_<V>) => void): void;
|
||||
onDestroy(): void;
|
||||
|
@ -429,18 +429,18 @@ export interface ForwardRefFn {
|
|||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare function getDebugNode(nativeNode: any): DebugNode;
|
||||
export declare function getDebugNode(nativeNode: any): DebugNode | null;
|
||||
|
||||
/** @experimental */
|
||||
export declare function getModuleFactory(id: string): NgModuleFactory<any>;
|
||||
|
||||
/** @experimental */
|
||||
export declare function getPlatform(): PlatformRef;
|
||||
export declare function getPlatform(): PlatformRef | null;
|
||||
|
||||
/** @experimental */
|
||||
export interface GetTestability {
|
||||
addToWindow(registry: TestabilityRegistry): void;
|
||||
findTestabilityInTree(registry: TestabilityRegistry, elem: any, findInAncestors: boolean): Testability;
|
||||
findTestabilityInTree(registry: TestabilityRegistry, elem: any, findInAncestors: boolean): Testability | null;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
|
@ -501,10 +501,10 @@ export declare function isDevMode(): boolean;
|
|||
|
||||
/** @stable */
|
||||
export interface IterableChangeRecord<V> {
|
||||
currentIndex: number;
|
||||
item: V;
|
||||
previousIndex: number;
|
||||
trackById: any;
|
||||
readonly currentIndex: number | null;
|
||||
readonly item: V;
|
||||
readonly previousIndex: number | null;
|
||||
readonly trackById: any;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
|
@ -520,7 +520,7 @@ export interface IterableChanges<V> {
|
|||
|
||||
/** @stable */
|
||||
export interface IterableDiffer<V> {
|
||||
diff(object: NgIterable<V>): IterableChanges<V>;
|
||||
diff(object: NgIterable<V>): IterableChanges<V> | null;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
|
@ -544,9 +544,9 @@ export declare function keyframes(steps: AnimationStyleMetadata[]): AnimationKey
|
|||
|
||||
/** @stable */
|
||||
export interface KeyValueChangeRecord<K, V> {
|
||||
currentValue: V;
|
||||
key: K;
|
||||
previousValue: V;
|
||||
readonly currentValue: V | null;
|
||||
readonly key: K;
|
||||
readonly previousValue: V | null;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
|
@ -617,7 +617,7 @@ export declare class NgModuleFactory<T> {
|
|||
constructor(_injectorClass: {
|
||||
new (parentInjector: Injector): NgModuleInjector<T>;
|
||||
}, _moduleType: Type<T>);
|
||||
create(parentInjector: Injector): NgModuleRef<T>;
|
||||
create(parentInjector: Injector | null): NgModuleRef<T>;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
|
@ -730,7 +730,7 @@ export declare abstract class PlatformRef {
|
|||
|
||||
/** @experimental */
|
||||
export interface Predicate<T> {
|
||||
(value: T, index?: number, array?: T[]): boolean;
|
||||
(value: T): boolean;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
|
@ -748,7 +748,7 @@ export declare class QueryList<T> {
|
|||
readonly last: T;
|
||||
readonly length: number;
|
||||
filter(fn: (item: T, index: number, array: T[]) => boolean): T[];
|
||||
find(fn: (item: T, index: number, array: T[]) => boolean): T;
|
||||
find(fn: (item: T, index: number, array: T[]) => boolean): T | undefined;
|
||||
forEach(fn: (item: T, index: number, array: T[]) => void): void;
|
||||
map<U>(fn: (item: T, index: number, array: T[]) => U): U[];
|
||||
notifyOnChanges(): void;
|
||||
|
@ -762,7 +762,7 @@ export declare class QueryList<T> {
|
|||
|
||||
/** @stable */
|
||||
export declare abstract class ReflectiveInjector implements Injector {
|
||||
readonly abstract parent: Injector;
|
||||
readonly abstract parent: Injector | null;
|
||||
abstract createChildFromResolved(providers: ResolvedReflectiveProvider[]): ReflectiveInjector;
|
||||
abstract get(token: any, notFoundValue?: any): any;
|
||||
abstract instantiateResolved(provider: ResolvedReflectiveProvider): any;
|
||||
|
@ -822,23 +822,23 @@ export declare abstract class Renderer2 {
|
|||
readonly abstract data: {
|
||||
[key: string]: any;
|
||||
};
|
||||
destroyNode: (node: any) => void | null;
|
||||
destroyNode: ((node: any) => void) | null;
|
||||
abstract addClass(el: any, name: string): void;
|
||||
abstract appendChild(parent: any, newChild: any): void;
|
||||
abstract createComment(value: string): any;
|
||||
abstract createElement(name: string, namespace?: string): any;
|
||||
abstract createElement(name: string, namespace?: string | null): any;
|
||||
abstract createText(value: string): any;
|
||||
abstract destroy(): void;
|
||||
abstract insertBefore(parent: any, newChild: any, refChild: any): void;
|
||||
abstract listen(target: 'window' | 'document' | 'body' | any, eventName: string, callback: (event: any) => boolean | void): () => void;
|
||||
abstract nextSibling(node: any): any;
|
||||
abstract parentNode(node: any): any;
|
||||
abstract removeAttribute(el: any, name: string, namespace?: string): void;
|
||||
abstract removeAttribute(el: any, name: string, namespace?: string | null): void;
|
||||
abstract removeChild(parent: any, oldChild: any): void;
|
||||
abstract removeClass(el: any, name: string): void;
|
||||
abstract removeStyle(el: any, style: string, flags?: RendererStyleFlags2): void;
|
||||
abstract selectRootElement(selectorOrNode: string | any): any;
|
||||
abstract setAttribute(el: any, name: string, value: string, namespace?: string): void;
|
||||
abstract setAttribute(el: any, name: string, value: string, namespace?: string | null): void;
|
||||
abstract setProperty(el: any, name: string, value: any): void;
|
||||
abstract setStyle(el: any, style: string, value: any, flags?: RendererStyleFlags2): void;
|
||||
abstract setValue(node: any, value: string): void;
|
||||
|
@ -846,7 +846,7 @@ export declare abstract class Renderer2 {
|
|||
|
||||
/** @experimental */
|
||||
export declare abstract class RendererFactory2 {
|
||||
abstract createRenderer(hostElement: any, type: RendererType2): Renderer2;
|
||||
abstract createRenderer(hostElement: any, type: RendererType2 | null): Renderer2;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
|
@ -990,10 +990,10 @@ export declare class Testability implements PublicTestability {
|
|||
/** @experimental */
|
||||
export declare class TestabilityRegistry {
|
||||
constructor();
|
||||
findTestabilityInTree(elem: Node, findInAncestors?: boolean): Testability;
|
||||
findTestabilityInTree(elem: Node, findInAncestors?: boolean): Testability | null;
|
||||
getAllRootElements(): any[];
|
||||
getAllTestabilities(): Testability[];
|
||||
getTestability(elem: any): Testability;
|
||||
getTestability(elem: any): Testability | null;
|
||||
registerApplication(token: any, testability: Testability): void;
|
||||
}
|
||||
|
||||
|
@ -1088,8 +1088,8 @@ export declare abstract class ViewContainerRef {
|
|||
abstract clear(): void;
|
||||
abstract createComponent<C>(componentFactory: ComponentFactory<C>, index?: number, injector?: Injector, projectableNodes?: any[][], ngModule?: NgModuleRef<any>): ComponentRef<C>;
|
||||
abstract createEmbeddedView<C>(templateRef: TemplateRef<C>, context?: C, index?: number): EmbeddedViewRef<C>;
|
||||
abstract detach(index?: number): ViewRef;
|
||||
abstract get(index: number): ViewRef;
|
||||
abstract detach(index?: number): ViewRef | null;
|
||||
abstract get(index: number): ViewRef | null;
|
||||
abstract indexOf(viewRef: ViewRef): number;
|
||||
abstract insert(viewRef: ViewRef, index?: number): ViewRef;
|
||||
abstract move(viewRef: ViewRef, currentIndex: number): ViewRef;
|
||||
|
|
|
@ -9,8 +9,8 @@ export declare class ComponentFixture<T> {
|
|||
debugElement: DebugElement;
|
||||
elementRef: ElementRef;
|
||||
nativeElement: any;
|
||||
ngZone: NgZone;
|
||||
constructor(componentRef: ComponentRef<T>, ngZone: NgZone, _autoDetect: boolean);
|
||||
ngZone: NgZone | null;
|
||||
constructor(componentRef: ComponentRef<T>, ngZone: NgZone | null, _autoDetect: boolean);
|
||||
autoDetectChanges(autoDetect?: boolean): void;
|
||||
checkNoChanges(): void;
|
||||
destroy(): void;
|
||||
|
|
Loading…
Reference in New Issue