@ -34,9 +34,9 @@ export const APP_INITIALIZER = new InjectionToken<Array<() => void>>('Applicatio
|
||||
@Injectable()
|
||||
export class ApplicationInitStatus {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
private resolve !: Function;
|
||||
private resolve!: Function;
|
||||
// TODO(issue/24571): remove '!'.
|
||||
private reject !: Function;
|
||||
private reject!: Function;
|
||||
private initialized = false;
|
||||
public readonly donePromise: Promise<any>;
|
||||
public readonly done = false;
|
||||
@ -57,7 +57,7 @@ export class ApplicationInitStatus {
|
||||
const asyncInitPromises: Promise<any>[] = [];
|
||||
|
||||
const complete = () => {
|
||||
(this as{done: boolean}).done = true;
|
||||
(this as {done: boolean}).done = true;
|
||||
this.resolve();
|
||||
};
|
||||
|
||||
@ -70,7 +70,13 @@ export class ApplicationInitStatus {
|
||||
}
|
||||
}
|
||||
|
||||
Promise.all(asyncInitPromises).then(() => { complete(); }).catch(e => { this.reject(e); });
|
||||
Promise.all(asyncInitPromises)
|
||||
.then(() => {
|
||||
complete();
|
||||
})
|
||||
.catch(e => {
|
||||
this.reject(e);
|
||||
});
|
||||
|
||||
if (asyncInitPromises.length === 0) {
|
||||
complete();
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {APP_INITIALIZER, ApplicationInitStatus} from './application_init';
|
||||
import {ApplicationRef} from './application_ref';
|
||||
import {APP_ID_RANDOM_PROVIDER} from './application_tokens';
|
||||
import {IterableDiffers, KeyValueDiffers, defaultIterableDiffers, defaultKeyValueDiffers} from './change_detection/change_detection';
|
||||
import {defaultIterableDiffers, defaultKeyValueDiffers, IterableDiffers, KeyValueDiffers} from './change_detection/change_detection';
|
||||
import {Console} from './console';
|
||||
import {Injector, StaticProvider} from './di';
|
||||
import {Inject, Optional, SkipSelf} from './di/metadata';
|
||||
@ -78,8 +78,7 @@ export const APPLICATION_MODULE_PROVIDERS: StaticProvider[] = [
|
||||
{
|
||||
provide: ApplicationRef,
|
||||
useClass: ApplicationRef,
|
||||
deps:
|
||||
[NgZone, Console, Injector, ErrorHandler, ComponentFactoryResolver, ApplicationInitStatus]
|
||||
deps: [NgZone, Console, Injector, ErrorHandler, ComponentFactoryResolver, ApplicationInitStatus]
|
||||
},
|
||||
{provide: SCHEDULER, deps: [NgZone], useFactory: zoneSchedulerFactory},
|
||||
{
|
||||
@ -112,10 +111,12 @@ export function zoneSchedulerFactory(ngZone: NgZone): (fn: () => void) => void {
|
||||
let queue: (() => void)[] = [];
|
||||
ngZone.onStable.subscribe(() => {
|
||||
while (queue.length) {
|
||||
queue.pop() !();
|
||||
queue.pop()!();
|
||||
}
|
||||
});
|
||||
return function(fn: () => void) { queue.push(fn); };
|
||||
return function(fn: () => void) {
|
||||
queue.push(fn);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import './util/ng_jit_mode';
|
||||
|
||||
import {Observable, Observer, Subscription, merge} from 'rxjs';
|
||||
import {merge, Observable, Observer, Subscription} from 'rxjs';
|
||||
import {share} from 'rxjs/operators';
|
||||
|
||||
import {ApplicationInitStatus} from './application_init';
|
||||
@ -80,7 +80,7 @@ export function compileNgModuleFactory__POST_R3__<M>(
|
||||
return Promise.resolve(moduleFactory);
|
||||
}
|
||||
|
||||
const compilerProviders = _mergeArrays(compilerOptions.map(o => o.providers !));
|
||||
const compilerProviders = _mergeArrays(compilerOptions.map(o => o.providers!));
|
||||
|
||||
// In case there are no compiler providers, we just return the module factory as
|
||||
// there won't be any resource loader. This can happen with Ivy, because AOT compiled
|
||||
@ -157,9 +157,8 @@ export function createPlatform(injector: Injector): PlatformRef {
|
||||
* @publicApi
|
||||
*/
|
||||
export function createPlatformFactory(
|
||||
parentPlatformFactory: ((extraProviders?: StaticProvider[]) => PlatformRef) | null,
|
||||
name: string, providers: StaticProvider[] = []): (extraProviders?: StaticProvider[]) =>
|
||||
PlatformRef {
|
||||
parentPlatformFactory: ((extraProviders?: StaticProvider[]) => PlatformRef)|null, name: string,
|
||||
providers: StaticProvider[] = []): (extraProviders?: StaticProvider[]) => PlatformRef {
|
||||
const desc = `Platform: ${name}`;
|
||||
const marker = new InjectionToken(desc);
|
||||
return (extraProviders: StaticProvider[] = []) => {
|
||||
@ -320,10 +319,12 @@ export class PlatformRef {
|
||||
throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
|
||||
}
|
||||
moduleRef.onDestroy(() => remove(this._modules, moduleRef));
|
||||
ngZone !.runOutsideAngular(
|
||||
() => ngZone !.onError.subscribe(
|
||||
{next: (error: any) => { exceptionHandler.handleError(error); }}));
|
||||
return _callAndReportToErrorHandler(exceptionHandler, ngZone !, () => {
|
||||
ngZone!.runOutsideAngular(() => ngZone!.onError.subscribe({
|
||||
next: (error: any) => {
|
||||
exceptionHandler.handleError(error);
|
||||
}
|
||||
}));
|
||||
return _callAndReportToErrorHandler(exceptionHandler, ngZone!, () => {
|
||||
const initStatus: ApplicationInitStatus = moduleRef.injector.get(ApplicationInitStatus);
|
||||
initStatus.runInitializers();
|
||||
return initStatus.donePromise.then(() => {
|
||||
@ -356,7 +357,8 @@ export class PlatformRef {
|
||||
*
|
||||
*/
|
||||
bootstrapModule<M>(
|
||||
moduleType: Type<M>, compilerOptions: (CompilerOptions&BootstrapOptions)|
|
||||
moduleType: Type<M>,
|
||||
compilerOptions: (CompilerOptions&BootstrapOptions)|
|
||||
Array<CompilerOptions&BootstrapOptions> = []): Promise<NgModuleRef<M>> {
|
||||
const options = optionsReducer({}, compilerOptions);
|
||||
return compileNgModuleFactory(this.injector, options, moduleType)
|
||||
@ -371,7 +373,10 @@ export class PlatformRef {
|
||||
moduleRef.instance.ngDoBootstrap(appRef);
|
||||
} else {
|
||||
throw new Error(
|
||||
`The module ${stringify(moduleRef.instance.constructor)} was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` +
|
||||
`The module ${
|
||||
stringify(
|
||||
moduleRef.instance
|
||||
.constructor)} was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` +
|
||||
`Please define one of these.`);
|
||||
}
|
||||
this._modules.push(moduleRef);
|
||||
@ -380,13 +385,17 @@ export class PlatformRef {
|
||||
/**
|
||||
* Register a listener to be called when the platform is disposed.
|
||||
*/
|
||||
onDestroy(callback: () => void): void { this._destroyListeners.push(callback); }
|
||||
onDestroy(callback: () => void): void {
|
||||
this._destroyListeners.push(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the platform {@link Injector}, which is the parent injector for
|
||||
* every Angular application on the page and provides singleton providers.
|
||||
*/
|
||||
get injector(): Injector { return this._injector; }
|
||||
get injector(): Injector {
|
||||
return this._injector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the Angular platform and all Angular applications on the page.
|
||||
@ -400,11 +409,13 @@ export class PlatformRef {
|
||||
this._destroyed = true;
|
||||
}
|
||||
|
||||
get destroyed() { return this._destroyed; }
|
||||
get destroyed() {
|
||||
return this._destroyed;
|
||||
}
|
||||
}
|
||||
|
||||
function getNgZone(
|
||||
ngZoneOption: NgZone | 'zone.js' | 'noop' | undefined, ngZoneEventCoalescing: boolean): NgZone {
|
||||
ngZoneOption: NgZone|'zone.js'|'noop'|undefined, ngZoneEventCoalescing: boolean): NgZone {
|
||||
let ngZone: NgZone;
|
||||
|
||||
if (ngZoneOption === 'noop') {
|
||||
@ -438,7 +449,7 @@ function _callAndReportToErrorHandler(
|
||||
}
|
||||
}
|
||||
|
||||
function optionsReducer<T extends Object>(dst: any, objs: T | T[]): T {
|
||||
function optionsReducer<T extends Object>(dst: any, objs: T|T[]): T {
|
||||
if (Array.isArray(objs)) {
|
||||
dst = objs.reduce(optionsReducer, dst);
|
||||
} else {
|
||||
@ -566,7 +577,7 @@ export class ApplicationRef {
|
||||
* @see [Usage notes](#is-stable-examples) for examples and caveats when using this API.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
public readonly isStable !: Observable<boolean>;
|
||||
public readonly isStable!: Observable<boolean>;
|
||||
|
||||
/** @internal */
|
||||
constructor(
|
||||
@ -576,8 +587,13 @@ export class ApplicationRef {
|
||||
private _initStatus: ApplicationInitStatus) {
|
||||
this._enforceNoNewChanges = isDevMode();
|
||||
|
||||
this._zone.onMicrotaskEmpty.subscribe(
|
||||
{next: () => { this._zone.run(() => { this.tick(); }); }});
|
||||
this._zone.onMicrotaskEmpty.subscribe({
|
||||
next: () => {
|
||||
this._zone.run(() => {
|
||||
this.tick();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const isCurrentlyStable = new Observable<boolean>((observer: Observer<boolean>) => {
|
||||
this._stable = this._zone.isStable && !this._zone.hasPendingMacrotasks &&
|
||||
@ -612,7 +628,9 @@ export class ApplicationRef {
|
||||
NgZone.assertInAngularZone();
|
||||
if (this._stable) {
|
||||
this._stable = false;
|
||||
this._zone.runOutsideAngular(() => { observer.next(false); });
|
||||
this._zone.runOutsideAngular(() => {
|
||||
observer.next(false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -622,7 +640,7 @@ export class ApplicationRef {
|
||||
};
|
||||
});
|
||||
|
||||
(this as{isStable: Observable<boolean>}).isStable =
|
||||
(this as {isStable: Observable<boolean>}).isStable =
|
||||
merge(isCurrentlyStable, isStable.pipe(share()));
|
||||
}
|
||||
|
||||
@ -653,7 +671,7 @@ export class ApplicationRef {
|
||||
componentFactory = componentOrFactory;
|
||||
} else {
|
||||
componentFactory =
|
||||
this._componentFactoryResolver.resolveComponentFactory(componentOrFactory) !;
|
||||
this._componentFactoryResolver.resolveComponentFactory(componentOrFactory)!;
|
||||
}
|
||||
this.componentTypes.push(componentFactory.componentType);
|
||||
|
||||
@ -663,7 +681,9 @@ export class ApplicationRef {
|
||||
const selectorOrNode = rootSelectorOrNode || componentFactory.selector;
|
||||
const compRef = componentFactory.create(Injector.NULL, [], selectorOrNode, ngModule);
|
||||
|
||||
compRef.onDestroy(() => { this._unloadComponent(compRef); });
|
||||
compRef.onDestroy(() => {
|
||||
this._unloadComponent(compRef);
|
||||
});
|
||||
const testability = compRef.injector.get(Testability, null);
|
||||
if (testability) {
|
||||
compRef.injector.get(TestabilityRegistry)
|
||||
@ -755,7 +775,9 @@ export class ApplicationRef {
|
||||
/**
|
||||
* Returns the number of attached views.
|
||||
*/
|
||||
get viewCount() { return this._views.length; }
|
||||
get viewCount() {
|
||||
return this._views.length;
|
||||
}
|
||||
}
|
||||
|
||||
function remove<T>(list: T[], el: T): void {
|
||||
|
@ -11,26 +11,16 @@ import {DefaultKeyValueDifferFactory} from './differs/default_keyvalue_differ';
|
||||
import {IterableDifferFactory, IterableDiffers} from './differs/iterable_differs';
|
||||
import {KeyValueDifferFactory, KeyValueDiffers} from './differs/keyvalue_differs';
|
||||
|
||||
export {WrappedValue, devModeEqual} from './change_detection_util';
|
||||
export {SimpleChange, SimpleChanges} from '../interface/simple_change';
|
||||
export {devModeEqual, WrappedValue} from './change_detection_util';
|
||||
export {ChangeDetectorRef} from './change_detector_ref';
|
||||
export {ChangeDetectionStrategy, ChangeDetectorStatus, isDefaultChangeDetectionStrategy} from './constants';
|
||||
export {DefaultIterableDifferFactory} from './differs/default_iterable_differ';
|
||||
export {DefaultIterableDiffer} from './differs/default_iterable_differ';
|
||||
export {DefaultKeyValueDifferFactory} from './differs/default_keyvalue_differ';
|
||||
export {
|
||||
CollectionChangeRecord,
|
||||
IterableChangeRecord,
|
||||
IterableChanges,
|
||||
IterableDiffer,
|
||||
IterableDifferFactory,
|
||||
IterableDiffers,
|
||||
NgIterable,
|
||||
TrackByFunction
|
||||
} from
|
||||
'./differs/iterable_differs';
|
||||
export {CollectionChangeRecord, IterableChangeRecord, IterableChanges, IterableDiffer, IterableDifferFactory, IterableDiffers, NgIterable, TrackByFunction} from './differs/iterable_differs';
|
||||
export {KeyValueChangeRecord, KeyValueChanges, KeyValueDiffer, KeyValueDifferFactory, KeyValueDiffers} from './differs/keyvalue_differs';
|
||||
export {PipeTransform} from './pipe_transform';
|
||||
export {SimpleChange, SimpleChanges} from '../interface/simple_change';
|
||||
|
||||
|
||||
|
||||
|
@ -49,19 +49,27 @@ export class WrappedValue {
|
||||
/** @deprecated from 5.3, use `unwrap()` instead - will switch to protected */
|
||||
wrapped: any;
|
||||
|
||||
constructor(value: any) { this.wrapped = value; }
|
||||
constructor(value: any) {
|
||||
this.wrapped = value;
|
||||
}
|
||||
|
||||
/** Creates a wrapped value. */
|
||||
static wrap(value: any): WrappedValue { return new WrappedValue(value); }
|
||||
static wrap(value: any): WrappedValue {
|
||||
return new WrappedValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying value of a wrapped value.
|
||||
* Returns the given `value` when it is not wrapped.
|
||||
**/
|
||||
static unwrap(value: any): any { return WrappedValue.isWrapped(value) ? value.wrapped : value; }
|
||||
static unwrap(value: any): any {
|
||||
return WrappedValue.isWrapped(value) ? value.wrapped : value;
|
||||
}
|
||||
|
||||
/** Returns true if `value` is a wrapped value. */
|
||||
static isWrapped(value: any): value is WrappedValue { return value instanceof WrappedValue; }
|
||||
static isWrapped(value: any): value is WrappedValue {
|
||||
return value instanceof WrappedValue;
|
||||
}
|
||||
}
|
||||
|
||||
export function isListLikeIterable(obj: any): boolean {
|
||||
|
@ -15,7 +15,9 @@ import {IterableChangeRecord, IterableChanges, IterableDiffer, IterableDifferFac
|
||||
|
||||
export class DefaultIterableDifferFactory implements IterableDifferFactory {
|
||||
constructor() {}
|
||||
supports(obj: Object|null|undefined): boolean { return isListLikeIterable(obj); }
|
||||
supports(obj: Object|null|undefined): boolean {
|
||||
return isListLikeIterable(obj);
|
||||
}
|
||||
|
||||
create<V>(trackByFn?: TrackByFunction<V>): DefaultIterableDiffer<V> {
|
||||
return new DefaultIterableDiffer<V>(trackByFn);
|
||||
@ -31,7 +33,7 @@ const trackByIdentity = (index: number, item: any) => item;
|
||||
export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChanges<V> {
|
||||
public readonly length: number = 0;
|
||||
// TODO(issue/24571): remove '!'.
|
||||
public readonly collection !: V[] | Iterable<V>| null;
|
||||
public readonly collection!: V[]|Iterable<V>|null;
|
||||
// Keeps track of the used records at any point in time (during & across `_check()` calls)
|
||||
private _linkedRecords: _DuplicateMap<V>|null = null;
|
||||
// Keeps track of the removed records at any point in time during `_check()` calls.
|
||||
@ -50,7 +52,9 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
||||
private _identityChangesTail: IterableChangeRecord_<V>|null = null;
|
||||
private _trackByFn: TrackByFunction<V>;
|
||||
|
||||
constructor(trackByFn?: TrackByFunction<V>) { this._trackByFn = trackByFn || trackByIdentity; }
|
||||
constructor(trackByFn?: TrackByFunction<V>) {
|
||||
this._trackByFn = trackByFn || trackByIdentity;
|
||||
}
|
||||
|
||||
forEachItem(fn: (record: IterableChangeRecord_<V>) => void) {
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
@ -71,9 +75,9 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
||||
// Order: remove, add, move
|
||||
const record: IterableChangeRecord<V> = !nextRemove ||
|
||||
nextIt &&
|
||||
nextIt.currentIndex ! <
|
||||
nextIt.currentIndex! <
|
||||
getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ?
|
||||
nextIt ! :
|
||||
nextIt! :
|
||||
nextRemove;
|
||||
const adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
|
||||
const currentIndex = record.currentIndex;
|
||||
@ -83,14 +87,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);
|
||||
@ -171,7 +175,7 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
||||
let item: V;
|
||||
let itemTrackBy: any;
|
||||
if (Array.isArray(collection)) {
|
||||
(this as{length: number}).length = collection.length;
|
||||
(this as {length: number}).length = collection.length;
|
||||
|
||||
for (let index = 0; index < this.length; index++) {
|
||||
item = collection[index];
|
||||
@ -206,11 +210,11 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
||||
record = record._next;
|
||||
index++;
|
||||
});
|
||||
(this as{length: number}).length = index;
|
||||
(this as {length: number}).length = index;
|
||||
}
|
||||
|
||||
this._truncate(record);
|
||||
(this as{collection: V[] | Iterable<V>}).collection = collection;
|
||||
(this as {collection: V[] | Iterable<V>}).collection = collection;
|
||||
return this.isDirty;
|
||||
}
|
||||
|
||||
@ -338,7 +342,7 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
|
||||
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);
|
||||
@ -611,7 +615,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;
|
||||
@ -623,7 +627,7 @@ class _DuplicateItemRecordList<V> {
|
||||
get(trackById: any, atOrAfterIndex: number|null): IterableChangeRecord_<V>|null {
|
||||
let record: IterableChangeRecord_<V>|null;
|
||||
for (record = this._head; record !== null; record = record._nextDup) {
|
||||
if ((atOrAfterIndex === null || atOrAfterIndex <= record.currentIndex !) &&
|
||||
if ((atOrAfterIndex === null || atOrAfterIndex <= record.currentIndex!) &&
|
||||
looseIdentical(record.trackById, trackById)) {
|
||||
return record;
|
||||
}
|
||||
@ -696,7 +700,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);
|
||||
@ -704,13 +708,16 @@ class _DuplicateMap<V> {
|
||||
return record;
|
||||
}
|
||||
|
||||
get isEmpty(): boolean { return this.map.size === 0; }
|
||||
get isEmpty(): boolean {
|
||||
return this.map.size === 0;
|
||||
}
|
||||
|
||||
clear() { this.map.clear(); }
|
||||
clear() {
|
||||
this.map.clear();
|
||||
}
|
||||
}
|
||||
|
||||
function getPreviousIndex(
|
||||
item: any, addRemoveOffset: number, moveOffsets: number[] | null): number {
|
||||
function getPreviousIndex(item: any, addRemoveOffset: number, moveOffsets: number[]|null): number {
|
||||
const previousIndex = item.previousIndex;
|
||||
if (previousIndex === null) return previousIndex;
|
||||
let moveOffset = 0;
|
||||
|
@ -14,9 +14,13 @@ import {KeyValueChangeRecord, KeyValueChanges, KeyValueDiffer, KeyValueDifferFac
|
||||
|
||||
export class DefaultKeyValueDifferFactory<K, V> implements KeyValueDifferFactory {
|
||||
constructor() {}
|
||||
supports(obj: any): boolean { return obj instanceof Map || isJsObject(obj); }
|
||||
supports(obj: any): boolean {
|
||||
return obj instanceof Map || isJsObject(obj);
|
||||
}
|
||||
|
||||
create<K, V>(): KeyValueDiffer<K, V> { return new DefaultKeyValueDiffer<K, V>(); }
|
||||
create<K, V>(): KeyValueDiffer<K, V> {
|
||||
return new DefaultKeyValueDiffer<K, V>();
|
||||
}
|
||||
}
|
||||
|
||||
export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyValueChanges<K, V> {
|
||||
@ -175,7 +179,7 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
|
||||
|
||||
private _getOrCreateRecordForKey(key: K, value: V): KeyValueChangeRecord_<K, V> {
|
||||
if (this._records.has(key)) {
|
||||
const record = this._records.get(key) !;
|
||||
const record = this._records.get(key)!;
|
||||
this._maybeAddToChanges(record, value);
|
||||
const prev = record._prev;
|
||||
const next = record._next;
|
||||
@ -236,7 +240,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;
|
||||
}
|
||||
}
|
||||
@ -245,7 +249,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;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import {DefaultIterableDifferFactory} from '../differs/default_iterable_differ';
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export type NgIterable<T> = Array<T>| Iterable<T>;
|
||||
export type NgIterable<T> = Array<T>|Iterable<T>;
|
||||
|
||||
/**
|
||||
* A strategy for tracking changes over time to an iterable. Used by {@link NgForOf} to
|
||||
@ -86,8 +86,10 @@ export interface IterableChanges<V> {
|
||||
/** Iterate over all removed items. */
|
||||
forEachRemovedItem(fn: (record: IterableChangeRecord<V>) => void): void;
|
||||
|
||||
/** Iterate over all items which had their identity (as computed by the `TrackByFunction`)
|
||||
* changed. */
|
||||
/**
|
||||
* Iterate over all items which had their identity (as computed by the `TrackByFunction`)
|
||||
* changed.
|
||||
*/
|
||||
forEachIdentityChange(fn: (record: IterableChangeRecord<V>) => void): void;
|
||||
}
|
||||
|
||||
@ -124,7 +126,9 @@ export interface CollectionChangeRecord<V> extends IterableChangeRecord<V> {}
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface TrackByFunction<T> { (index: number, item: T): any; }
|
||||
export interface TrackByFunction<T> {
|
||||
(index: number, item: T): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a factory for {@link IterableDiffer}.
|
||||
@ -153,7 +157,9 @@ export class IterableDiffers {
|
||||
* @deprecated v4.0.0 - Should be private
|
||||
*/
|
||||
factories: IterableDifferFactory[];
|
||||
constructor(factories: IterableDifferFactory[]) { this.factories = factories; }
|
||||
constructor(factories: IterableDifferFactory[]) {
|
||||
this.factories = factories;
|
||||
}
|
||||
|
||||
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers {
|
||||
if (parent != null) {
|
||||
@ -206,8 +212,8 @@ export class IterableDiffers {
|
||||
if (factory != null) {
|
||||
return factory;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'`);
|
||||
throw new Error(`Cannot find a differ supporting object '${iterable}' of type '${
|
||||
getTypeNameForDebugging(iterable)}'`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,9 @@ export class KeyValueDiffers {
|
||||
*/
|
||||
factories: KeyValueDifferFactory[];
|
||||
|
||||
constructor(factories: KeyValueDifferFactory[]) { this.factories = factories; }
|
||||
constructor(factories: KeyValueDifferFactory[]) {
|
||||
this.factories = factories;
|
||||
}
|
||||
|
||||
static create<S>(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers {
|
||||
if (parent) {
|
||||
|
@ -30,4 +30,6 @@
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface PipeTransform { transform(value: any, ...args: any[]): any; }
|
||||
export interface PipeTransform {
|
||||
transform(value: any, ...args: any[]): any;
|
||||
}
|
||||
|
@ -8,4 +8,4 @@
|
||||
|
||||
export {CodegenComponentFactoryResolver as ɵCodegenComponentFactoryResolver} from './linker/component_factory_resolver';
|
||||
export {registerModuleFactory as ɵregisterModuleFactory} from './linker/ng_module_factory_registration';
|
||||
export {ArgumentType as ɵArgumentType, BindingFlags as ɵBindingFlags, DepFlags as ɵDepFlags, EMPTY_ARRAY as ɵEMPTY_ARRAY, EMPTY_MAP as ɵEMPTY_MAP, NodeFlags as ɵNodeFlags, QueryBindingType as ɵQueryBindingType, QueryValueType as ɵQueryValueType, ViewDefinition as ɵViewDefinition, ViewFlags as ɵViewFlags, anchorDef as ɵand, createComponentFactory as ɵccf, createNgModuleFactory as ɵcmf, createRendererType2 as ɵcrt, directiveDef as ɵdid, elementDef as ɵeld, getComponentViewDefinitionFactory as ɵgetComponentViewDefinitionFactory, inlineInterpolate as ɵinlineInterpolate, interpolate as ɵinterpolate, moduleDef as ɵmod, moduleProvideDef as ɵmpd, ngContentDef as ɵncd, nodeValue as ɵnov, pipeDef as ɵpid, providerDef as ɵprd, pureArrayDef as ɵpad, pureObjectDef as ɵpod, purePipeDef as ɵppd, queryDef as ɵqud, textDef as ɵted, unwrapValue as ɵunv, viewDef as ɵvid} from './view/index';
|
||||
export {anchorDef as ɵand, ArgumentType as ɵArgumentType, BindingFlags as ɵBindingFlags, createComponentFactory as ɵccf, createNgModuleFactory as ɵcmf, createRendererType2 as ɵcrt, DepFlags as ɵDepFlags, directiveDef as ɵdid, elementDef as ɵeld, EMPTY_ARRAY as ɵEMPTY_ARRAY, EMPTY_MAP as ɵEMPTY_MAP, getComponentViewDefinitionFactory as ɵgetComponentViewDefinitionFactory, inlineInterpolate as ɵinlineInterpolate, interpolate as ɵinterpolate, moduleDef as ɵmod, moduleProvideDef as ɵmpd, ngContentDef as ɵncd, NodeFlags as ɵNodeFlags, nodeValue as ɵnov, pipeDef as ɵpid, providerDef as ɵprd, pureArrayDef as ɵpad, pureObjectDef as ɵpod, purePipeDef as ɵppd, QueryBindingType as ɵQueryBindingType, queryDef as ɵqud, QueryValueType as ɵQueryValueType, textDef as ɵted, unwrapValue as ɵunv, viewDef as ɵvid, ViewDefinition as ɵViewDefinition, ViewFlags as ɵViewFlags} from './view/index';
|
||||
|
@ -22,7 +22,9 @@
|
||||
* ```
|
||||
*/
|
||||
|
||||
export interface ExportedCompilerFacade { ɵcompilerFacade: CompilerFacade; }
|
||||
export interface ExportedCompilerFacade {
|
||||
ɵcompilerFacade: CompilerFacade;
|
||||
}
|
||||
|
||||
export interface CompilerFacade {
|
||||
compilePipe(angularCoreEnv: CoreEnvironment, sourceMapUrl: string, meta: R3PipeMetadataFacade):
|
||||
@ -44,13 +46,15 @@ export interface CompilerFacade {
|
||||
|
||||
R3ResolvedDependencyType: typeof R3ResolvedDependencyType;
|
||||
R3FactoryTarget: typeof R3FactoryTarget;
|
||||
ResourceLoader: {new (): ResourceLoader};
|
||||
ResourceLoader: {new(): ResourceLoader};
|
||||
}
|
||||
|
||||
export interface CoreEnvironment { [name: string]: Function; }
|
||||
export interface CoreEnvironment {
|
||||
[name: string]: Function;
|
||||
}
|
||||
|
||||
export type ResourceLoader = {
|
||||
get(url: string): Promise<string>| string;
|
||||
get(url: string): Promise<string>|string;
|
||||
};
|
||||
|
||||
export type StringMap = {
|
||||
@ -58,7 +62,7 @@ export type StringMap = {
|
||||
};
|
||||
|
||||
export type StringMapWithRename = {
|
||||
[key: string]: string | [string, string];
|
||||
[key: string]: string|[string, string];
|
||||
};
|
||||
|
||||
export type Provider = any;
|
||||
|
@ -16,7 +16,7 @@ export {getDebugNodeR2 as ɵgetDebugNodeR2} from './debug/debug_node';
|
||||
export {inject, setCurrentInjector as ɵsetCurrentInjector, ɵɵinject} from './di/injector_compatibility';
|
||||
export {getInjectableDef as ɵgetInjectableDef, ɵɵInjectableDef, ɵɵInjectorDef} from './di/interface/defs';
|
||||
export {INJECTOR_SCOPE as ɵINJECTOR_SCOPE} from './di/scope';
|
||||
export {CurrencyIndex as ɵCurrencyIndex, ExtraLocaleDataIndex as ɵExtraLocaleDataIndex, LocaleDataIndex as ɵLocaleDataIndex, findLocaleData as ɵfindLocaleData, getLocaleCurrencyCode as ɵgetLocaleCurrencyCode, getLocalePluralCase as ɵgetLocalePluralCase, registerLocaleData as ɵregisterLocaleData, unregisterAllLocaleData as ɵunregisterLocaleData} from './i18n/locale_data_api';
|
||||
export {CurrencyIndex as ɵCurrencyIndex, ExtraLocaleDataIndex as ɵExtraLocaleDataIndex, findLocaleData as ɵfindLocaleData, getLocaleCurrencyCode as ɵgetLocaleCurrencyCode, getLocalePluralCase as ɵgetLocalePluralCase, LocaleDataIndex as ɵLocaleDataIndex, registerLocaleData as ɵregisterLocaleData, unregisterAllLocaleData as ɵunregisterLocaleData} from './i18n/locale_data_api';
|
||||
export {DEFAULT_LOCALE_ID as ɵDEFAULT_LOCALE_ID} from './i18n/localization';
|
||||
export {ivyEnabled as ɵivyEnabled} from './ivy_switch';
|
||||
export {ComponentFactory as ɵComponentFactory} from './linker/component_factory';
|
||||
@ -24,7 +24,7 @@ export {CodegenComponentFactoryResolver as ɵCodegenComponentFactoryResolver} fr
|
||||
export {clearResolutionOfComponentResourcesQueue as ɵclearResolutionOfComponentResourcesQueue, resolveComponentResources as ɵresolveComponentResources} from './metadata/resource_loading';
|
||||
export {ReflectionCapabilities as ɵReflectionCapabilities} from './reflection/reflection_capabilities';
|
||||
export {GetterFn as ɵGetterFn, MethodFn as ɵMethodFn, SetterFn as ɵSetterFn} from './reflection/types';
|
||||
export {BypassType as ɵBypassType, SafeHtml as ɵSafeHtml, SafeResourceUrl as ɵSafeResourceUrl, SafeScript as ɵSafeScript, SafeStyle as ɵSafeStyle, SafeUrl as ɵSafeUrl, SafeValue as ɵSafeValue, allowSanitizationBypassAndThrow as ɵallowSanitizationBypassAndThrow, getSanitizationBypassType as ɵgetSanitizationBypassType, unwrapSafeValue as ɵunwrapSafeValue} from './sanitization/bypass';
|
||||
export {allowSanitizationBypassAndThrow as ɵallowSanitizationBypassAndThrow, BypassType as ɵBypassType, getSanitizationBypassType as ɵgetSanitizationBypassType, SafeHtml as ɵSafeHtml, SafeResourceUrl as ɵSafeResourceUrl, SafeScript as ɵSafeScript, SafeStyle as ɵSafeStyle, SafeUrl as ɵSafeUrl, SafeValue as ɵSafeValue, unwrapSafeValue as ɵunwrapSafeValue} from './sanitization/bypass';
|
||||
export {_sanitizeHtml as ɵ_sanitizeHtml} from './sanitization/html_sanitizer';
|
||||
export {_sanitizeStyle as ɵ_sanitizeStyle} from './sanitization/style_sanitizer';
|
||||
export {_sanitizeUrl as ɵ_sanitizeUrl} from './sanitization/url_sanitizer';
|
||||
|
@ -7,7 +7,101 @@
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
// we reexport these symbols just so that they are retained during the dead code elimination
|
||||
// performed by rollup while it's creating fesm files.
|
||||
//
|
||||
// no code actually imports these symbols from the @angular/core entry point
|
||||
export {
|
||||
compileNgModuleFactory__POST_R3__ as ɵcompileNgModuleFactory__POST_R3__,
|
||||
isBoundToModule__POST_R3__ as ɵisBoundToModule__POST_R3__
|
||||
} from './application_ref';
|
||||
export {
|
||||
SWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__ as ɵSWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__,
|
||||
} from './change_detection/change_detector_ref';
|
||||
export {
|
||||
getDebugNode__POST_R3__ as ɵgetDebugNode__POST_R3__,
|
||||
} from './debug/debug_node';
|
||||
export {
|
||||
SWITCH_COMPILE_INJECTABLE__POST_R3__ as ɵSWITCH_COMPILE_INJECTABLE__POST_R3__,
|
||||
} from './di/injectable';
|
||||
export {INJECTOR_IMPL__POST_R3__ as ɵINJECTOR_IMPL__POST_R3__} from './di/injector';
|
||||
export {
|
||||
NG_INJ_DEF as ɵNG_INJ_DEF,
|
||||
NG_PROV_DEF as ɵNG_PROV_DEF,
|
||||
} from './di/interface/defs';
|
||||
export {createInjector as ɵcreateInjector} from './di/r3_injector';
|
||||
export {
|
||||
SWITCH_IVY_ENABLED__POST_R3__ as ɵSWITCH_IVY_ENABLED__POST_R3__,
|
||||
} from './ivy_switch';
|
||||
export {
|
||||
Compiler_compileModuleAndAllComponentsAsync__POST_R3__ as ɵCompiler_compileModuleAndAllComponentsAsync__POST_R3__,
|
||||
Compiler_compileModuleAndAllComponentsSync__POST_R3__ as ɵCompiler_compileModuleAndAllComponentsSync__POST_R3__,
|
||||
Compiler_compileModuleAsync__POST_R3__ as ɵCompiler_compileModuleAsync__POST_R3__,
|
||||
Compiler_compileModuleSync__POST_R3__ as ɵCompiler_compileModuleSync__POST_R3__,
|
||||
} from './linker/compiler';
|
||||
export {
|
||||
SWITCH_ELEMENT_REF_FACTORY__POST_R3__ as ɵSWITCH_ELEMENT_REF_FACTORY__POST_R3__,
|
||||
} from './linker/element_ref';
|
||||
export { getModuleFactory__POST_R3__ as ɵgetModuleFactory__POST_R3__ } from './linker/ng_module_factory_loader';
|
||||
export { registerNgModuleType as ɵregisterNgModuleType } from './linker/ng_module_factory_registration';
|
||||
export {
|
||||
SWITCH_TEMPLATE_REF_FACTORY__POST_R3__ as ɵSWITCH_TEMPLATE_REF_FACTORY__POST_R3__,
|
||||
} from './linker/template_ref';
|
||||
export {
|
||||
SWITCH_VIEW_CONTAINER_REF_FACTORY__POST_R3__ as ɵSWITCH_VIEW_CONTAINER_REF_FACTORY__POST_R3__,
|
||||
} from './linker/view_container_ref';
|
||||
export {
|
||||
SWITCH_COMPILE_COMPONENT__POST_R3__ as ɵSWITCH_COMPILE_COMPONENT__POST_R3__,
|
||||
SWITCH_COMPILE_DIRECTIVE__POST_R3__ as ɵSWITCH_COMPILE_DIRECTIVE__POST_R3__,
|
||||
SWITCH_COMPILE_PIPE__POST_R3__ as ɵSWITCH_COMPILE_PIPE__POST_R3__,
|
||||
} from './metadata/directives';
|
||||
export {
|
||||
NgModuleDef as ɵNgModuleDef,
|
||||
NgModuleTransitiveScopes as ɵNgModuleTransitiveScopes,
|
||||
ɵɵNgModuleDefWithMeta,
|
||||
} from './metadata/ng_module';
|
||||
export {
|
||||
SWITCH_COMPILE_NGMODULE__POST_R3__ as ɵSWITCH_COMPILE_NGMODULE__POST_R3__,
|
||||
} from './metadata/ng_module';
|
||||
export {
|
||||
SWITCH_RENDERER2_FACTORY__POST_R3__ as ɵSWITCH_RENDERER2_FACTORY__POST_R3__,
|
||||
} from './render/api';
|
||||
export {
|
||||
getLContext as ɵgetLContext
|
||||
} from './render3/context_discovery';
|
||||
export {
|
||||
NG_COMP_DEF as ɵNG_COMP_DEF,
|
||||
NG_DIR_DEF as ɵNG_DIR_DEF,
|
||||
NG_ELEMENT_ID as ɵNG_ELEMENT_ID,
|
||||
NG_MOD_DEF as ɵNG_MOD_DEF,
|
||||
NG_PIPE_DEF as ɵNG_PIPE_DEF,
|
||||
} from './render3/fields';
|
||||
export {
|
||||
AttributeMarker as ɵAttributeMarker,
|
||||
ComponentDef as ɵComponentDef,
|
||||
ComponentFactory as ɵRender3ComponentFactory,
|
||||
ComponentRef as ɵRender3ComponentRef,
|
||||
ComponentType as ɵComponentType,
|
||||
CssSelectorList as ɵCssSelectorList,
|
||||
detectChanges as ɵdetectChanges,
|
||||
DirectiveDef as ɵDirectiveDef,
|
||||
DirectiveType as ɵDirectiveType,
|
||||
getDirectives as ɵgetDirectives,
|
||||
getHostElement as ɵgetHostElement,
|
||||
LifecycleHooksFeature as ɵLifecycleHooksFeature,
|
||||
markDirty as ɵmarkDirty,
|
||||
NgModuleFactory as ɵNgModuleFactory,
|
||||
NgModuleRef as ɵRender3NgModuleRef,
|
||||
NgModuleType as ɵNgModuleType,
|
||||
NO_CHANGE as ɵNO_CHANGE,
|
||||
PipeDef as ɵPipeDef,
|
||||
renderComponent as ɵrenderComponent,
|
||||
RenderFlags as ɵRenderFlags,
|
||||
setClassMetadata as ɵsetClassMetadata,
|
||||
setLocaleId as ɵsetLocaleId,
|
||||
store as ɵstore,
|
||||
whenRendered as ɵwhenRendered,
|
||||
ɵɵadvance,
|
||||
ɵɵattribute,
|
||||
ɵɵattributeInterpolate1,
|
||||
ɵɵattributeInterpolate2,
|
||||
@ -18,88 +112,72 @@ export {
|
||||
ɵɵattributeInterpolate7,
|
||||
ɵɵattributeInterpolate8,
|
||||
ɵɵattributeInterpolateV,
|
||||
ɵɵclassMap,
|
||||
ɵɵclassMapInterpolate1,
|
||||
ɵɵclassMapInterpolate2,
|
||||
ɵɵclassMapInterpolate3,
|
||||
ɵɵclassMapInterpolate4,
|
||||
ɵɵclassMapInterpolate5,
|
||||
ɵɵclassMapInterpolate6,
|
||||
ɵɵclassMapInterpolate7,
|
||||
ɵɵclassMapInterpolate8,
|
||||
ɵɵclassMapInterpolateV,
|
||||
ɵɵclassProp,
|
||||
ɵɵComponentDefWithMeta,
|
||||
ɵɵcomponentHostSyntheticListener,
|
||||
ɵɵcontainer,
|
||||
ɵɵcontainerRefreshEnd,
|
||||
ɵɵcontainerRefreshStart,
|
||||
ɵɵcontentQuery,
|
||||
ɵɵCopyDefinitionFeature,
|
||||
ɵɵdefineComponent,
|
||||
ɵɵdefineDirective,
|
||||
ɵɵdefinePipe,
|
||||
ɵɵdefineNgModule,
|
||||
detectChanges as ɵdetectChanges,
|
||||
renderComponent as ɵrenderComponent,
|
||||
AttributeMarker as ɵAttributeMarker,
|
||||
ComponentType as ɵComponentType,
|
||||
ComponentFactory as ɵRender3ComponentFactory,
|
||||
ComponentRef as ɵRender3ComponentRef,
|
||||
DirectiveType as ɵDirectiveType,
|
||||
RenderFlags as ɵRenderFlags,
|
||||
ɵɵdefinePipe,
|
||||
ɵɵDirectiveDefWithMeta,
|
||||
ɵɵdirectiveInject,
|
||||
ɵɵdisableBindings,
|
||||
ɵɵelement,
|
||||
ɵɵelementContainer,
|
||||
ɵɵelementContainerEnd,
|
||||
ɵɵelementContainerStart,
|
||||
ɵɵelementEnd,
|
||||
ɵɵelementStart,
|
||||
ɵɵembeddedViewEnd,
|
||||
ɵɵembeddedViewStart,
|
||||
ɵɵenableBindings,
|
||||
ɵɵFactoryDef,
|
||||
ɵɵgetCurrentView,
|
||||
ɵɵgetFactoryOf,
|
||||
ɵɵgetInheritedFactory,
|
||||
ɵɵhostProperty,
|
||||
ɵɵi18n,
|
||||
ɵɵi18nApply,
|
||||
ɵɵi18nAttributes,
|
||||
ɵɵi18nEnd,
|
||||
ɵɵi18nExp,
|
||||
ɵɵi18nPostprocess,
|
||||
ɵɵi18nStart,
|
||||
ɵɵInheritDefinitionFeature,
|
||||
ɵɵinjectAttribute,
|
||||
ɵɵinjectPipeChangeDetectorRef,
|
||||
ɵɵinvalidFactory,
|
||||
ɵɵgetFactoryOf,
|
||||
ɵɵgetInheritedFactory,
|
||||
ɵɵsetComponentScope,
|
||||
ɵɵsetNgModuleScope,
|
||||
ɵɵtemplateRefExtractor,
|
||||
ɵɵProvidersFeature,
|
||||
ɵɵCopyDefinitionFeature,
|
||||
ɵɵInheritDefinitionFeature,
|
||||
ɵɵNgOnChangesFeature,
|
||||
LifecycleHooksFeature as ɵLifecycleHooksFeature,
|
||||
NgModuleType as ɵNgModuleType,
|
||||
NgModuleRef as ɵRender3NgModuleRef,
|
||||
CssSelectorList as ɵCssSelectorList,
|
||||
markDirty as ɵmarkDirty,
|
||||
NgModuleFactory as ɵNgModuleFactory,
|
||||
NO_CHANGE as ɵNO_CHANGE,
|
||||
ɵɵcontainer,
|
||||
ɵɵnextContext,
|
||||
ɵɵelementStart,
|
||||
ɵɵlistener,
|
||||
ɵɵloadQuery,
|
||||
ɵɵnamespaceHTML,
|
||||
ɵɵnamespaceMathML,
|
||||
ɵɵnamespaceSVG,
|
||||
ɵɵelement,
|
||||
ɵɵlistener,
|
||||
ɵɵtext,
|
||||
ɵɵtextInterpolate,
|
||||
ɵɵtextInterpolate1,
|
||||
ɵɵtextInterpolate2,
|
||||
ɵɵtextInterpolate3,
|
||||
ɵɵtextInterpolate4,
|
||||
ɵɵtextInterpolate5,
|
||||
ɵɵtextInterpolate6,
|
||||
ɵɵtextInterpolate7,
|
||||
ɵɵtextInterpolate8,
|
||||
ɵɵtextInterpolateV,
|
||||
ɵɵembeddedViewStart,
|
||||
ɵɵprojection,
|
||||
ɵɵnextContext,
|
||||
ɵɵNgOnChangesFeature,
|
||||
ɵɵpipe,
|
||||
ɵɵpipeBind1,
|
||||
ɵɵpipeBind2,
|
||||
ɵɵpipeBind3,
|
||||
ɵɵpipeBind4,
|
||||
ɵɵpipeBindV,
|
||||
ɵɵpureFunction0,
|
||||
ɵɵpureFunction1,
|
||||
ɵɵpureFunction2,
|
||||
ɵɵpureFunction3,
|
||||
ɵɵpureFunction4,
|
||||
ɵɵpureFunction5,
|
||||
ɵɵpureFunction6,
|
||||
ɵɵpureFunction7,
|
||||
ɵɵpureFunction8,
|
||||
ɵɵpureFunctionV,
|
||||
ɵɵgetCurrentView,
|
||||
getDirectives as ɵgetDirectives,
|
||||
getHostElement as ɵgetHostElement,
|
||||
ɵɵrestoreView,
|
||||
ɵɵcontainerRefreshStart,
|
||||
ɵɵcontainerRefreshEnd,
|
||||
ɵɵqueryRefresh,
|
||||
ɵɵviewQuery,
|
||||
ɵɵstaticViewQuery,
|
||||
ɵɵstaticContentQuery,
|
||||
ɵɵcontentQuery,
|
||||
ɵɵloadQuery,
|
||||
ɵɵelementEnd,
|
||||
ɵɵhostProperty,
|
||||
ɵɵPipeDefWithMeta,
|
||||
ɵɵprojection,
|
||||
ɵɵprojectionDef,
|
||||
ɵɵproperty,
|
||||
ɵɵpropertyInterpolate,
|
||||
ɵɵpropertyInterpolate1,
|
||||
@ -111,15 +189,29 @@ export {
|
||||
ɵɵpropertyInterpolate7,
|
||||
ɵɵpropertyInterpolate8,
|
||||
ɵɵpropertyInterpolateV,
|
||||
ɵɵupdateSyntheticHostBinding,
|
||||
ɵɵcomponentHostSyntheticListener,
|
||||
ɵɵprojectionDef,
|
||||
ɵɵProvidersFeature,
|
||||
ɵɵpureFunction0,
|
||||
ɵɵpureFunction1,
|
||||
ɵɵpureFunction2,
|
||||
ɵɵpureFunction3,
|
||||
ɵɵpureFunction4,
|
||||
ɵɵpureFunction5,
|
||||
ɵɵpureFunction6,
|
||||
ɵɵpureFunction7,
|
||||
ɵɵpureFunction8,
|
||||
ɵɵpureFunctionV,
|
||||
ɵɵqueryRefresh,
|
||||
ɵɵreference,
|
||||
ɵɵenableBindings,
|
||||
ɵɵdisableBindings,
|
||||
ɵɵelementContainerStart,
|
||||
ɵɵelementContainerEnd,
|
||||
ɵɵelementContainer,
|
||||
ɵɵresolveBody,
|
||||
ɵɵresolveDocument,
|
||||
ɵɵresolveWindow,
|
||||
ɵɵrestoreView,
|
||||
|
||||
ɵɵselect,
|
||||
ɵɵsetComponentScope,
|
||||
ɵɵsetNgModuleScope,
|
||||
ɵɵstaticContentQuery,
|
||||
ɵɵstaticViewQuery,
|
||||
ɵɵstyleMap,
|
||||
ɵɵstyleMapInterpolate1,
|
||||
ɵɵstyleMapInterpolate2,
|
||||
@ -130,17 +222,6 @@ export {
|
||||
ɵɵstyleMapInterpolate7,
|
||||
ɵɵstyleMapInterpolate8,
|
||||
ɵɵstyleMapInterpolateV,
|
||||
ɵɵstyleSanitizer,
|
||||
ɵɵclassMap,
|
||||
ɵɵclassMapInterpolate1,
|
||||
ɵɵclassMapInterpolate2,
|
||||
ɵɵclassMapInterpolate3,
|
||||
ɵɵclassMapInterpolate4,
|
||||
ɵɵclassMapInterpolate5,
|
||||
ɵɵclassMapInterpolate6,
|
||||
ɵɵclassMapInterpolate7,
|
||||
ɵɵclassMapInterpolate8,
|
||||
ɵɵclassMapInterpolateV,
|
||||
ɵɵstyleProp,
|
||||
ɵɵstylePropInterpolate1,
|
||||
ɵɵstylePropInterpolate2,
|
||||
@ -151,170 +232,72 @@ export {
|
||||
ɵɵstylePropInterpolate7,
|
||||
ɵɵstylePropInterpolate8,
|
||||
ɵɵstylePropInterpolateV,
|
||||
ɵɵclassProp,
|
||||
|
||||
ɵɵselect,
|
||||
ɵɵadvance,
|
||||
ɵɵstyleSanitizer,
|
||||
ɵɵtemplate,
|
||||
ɵɵembeddedViewEnd,
|
||||
store as ɵstore,
|
||||
ɵɵpipe,
|
||||
ComponentDef as ɵComponentDef,
|
||||
ɵɵComponentDefWithMeta,
|
||||
ɵɵFactoryDef,
|
||||
DirectiveDef as ɵDirectiveDef,
|
||||
ɵɵDirectiveDefWithMeta,
|
||||
PipeDef as ɵPipeDef,
|
||||
ɵɵPipeDefWithMeta,
|
||||
whenRendered as ɵwhenRendered,
|
||||
ɵɵi18n,
|
||||
ɵɵi18nAttributes,
|
||||
ɵɵi18nExp,
|
||||
ɵɵi18nStart,
|
||||
ɵɵi18nEnd,
|
||||
ɵɵi18nApply,
|
||||
ɵɵi18nPostprocess,
|
||||
setLocaleId as ɵsetLocaleId,
|
||||
setClassMetadata as ɵsetClassMetadata,
|
||||
ɵɵresolveWindow,
|
||||
ɵɵresolveDocument,
|
||||
ɵɵresolveBody,
|
||||
ɵɵtemplateRefExtractor,
|
||||
ɵɵtext,
|
||||
ɵɵtextInterpolate,
|
||||
ɵɵtextInterpolate1,
|
||||
ɵɵtextInterpolate2,
|
||||
ɵɵtextInterpolate3,
|
||||
ɵɵtextInterpolate4,
|
||||
ɵɵtextInterpolate5,
|
||||
ɵɵtextInterpolate6,
|
||||
ɵɵtextInterpolate7,
|
||||
ɵɵtextInterpolate8,
|
||||
ɵɵtextInterpolateV,
|
||||
ɵɵupdateSyntheticHostBinding,
|
||||
ɵɵviewQuery,
|
||||
} from './render3/index';
|
||||
|
||||
|
||||
export {
|
||||
LContext as ɵLContext,
|
||||
} from './render3/interfaces/context';
|
||||
export {
|
||||
setDocument as ɵsetDocument
|
||||
} from './render3/interfaces/document';
|
||||
export {
|
||||
Player as ɵPlayer,
|
||||
PlayerFactory as ɵPlayerFactory,
|
||||
PlayerHandler as ɵPlayerHandler,
|
||||
PlayState as ɵPlayState,
|
||||
} from './render3/interfaces/player';
|
||||
export {
|
||||
compileComponent as ɵcompileComponent,
|
||||
compileDirective as ɵcompileDirective,
|
||||
} from './render3/jit/directive';
|
||||
export {
|
||||
resetJitOptions as ɵresetJitOptions,
|
||||
} from './render3/jit/jit_options';
|
||||
export {
|
||||
compileNgModule as ɵcompileNgModule,
|
||||
compileNgModuleDefs as ɵcompileNgModuleDefs,
|
||||
flushModuleScopingQueueAsMuchAsPossible as ɵflushModuleScopingQueueAsMuchAsPossible,
|
||||
patchComponentDefWithScope as ɵpatchComponentDefWithScope,
|
||||
resetCompiledComponents as ɵresetCompiledComponents,
|
||||
flushModuleScopingQueueAsMuchAsPossible as ɵflushModuleScopingQueueAsMuchAsPossible,
|
||||
transitiveScopesFor as ɵtransitiveScopesFor,
|
||||
} from './render3/jit/module';
|
||||
export {
|
||||
compilePipe as ɵcompilePipe,
|
||||
} from './render3/jit/pipe';
|
||||
export {
|
||||
resetJitOptions as ɵresetJitOptions,
|
||||
} from './render3/jit/jit_options';
|
||||
|
||||
publishDefaultGlobalUtils as ɵpublishDefaultGlobalUtils
|
||||
,
|
||||
publishGlobalUtil as ɵpublishGlobalUtil} from './render3/util/global_utils';
|
||||
export {
|
||||
NgModuleDef as ɵNgModuleDef,
|
||||
ɵɵNgModuleDefWithMeta,
|
||||
NgModuleTransitiveScopes as ɵNgModuleTransitiveScopes,
|
||||
} from './metadata/ng_module';
|
||||
|
||||
bypassSanitizationTrustHtml as ɵbypassSanitizationTrustHtml,
|
||||
bypassSanitizationTrustResourceUrl as ɵbypassSanitizationTrustResourceUrl,
|
||||
bypassSanitizationTrustScript as ɵbypassSanitizationTrustScript,
|
||||
bypassSanitizationTrustStyle as ɵbypassSanitizationTrustStyle,
|
||||
bypassSanitizationTrustUrl as ɵbypassSanitizationTrustUrl,
|
||||
} from './sanitization/bypass';
|
||||
export {
|
||||
ɵɵsanitizeHtml,
|
||||
ɵɵsanitizeStyle,
|
||||
ɵɵdefaultStyleSanitizer,
|
||||
ɵɵsanitizeScript,
|
||||
ɵɵsanitizeUrl,
|
||||
ɵɵsanitizeHtml,
|
||||
ɵɵsanitizeResourceUrl,
|
||||
ɵɵsanitizeScript,
|
||||
ɵɵsanitizeStyle,
|
||||
ɵɵsanitizeUrl,
|
||||
ɵɵsanitizeUrlOrResourceUrl,
|
||||
} from './sanitization/sanitization';
|
||||
|
||||
export {
|
||||
bypassSanitizationTrustHtml as ɵbypassSanitizationTrustHtml,
|
||||
bypassSanitizationTrustStyle as ɵbypassSanitizationTrustStyle,
|
||||
bypassSanitizationTrustScript as ɵbypassSanitizationTrustScript,
|
||||
bypassSanitizationTrustUrl as ɵbypassSanitizationTrustUrl,
|
||||
bypassSanitizationTrustResourceUrl as ɵbypassSanitizationTrustResourceUrl,
|
||||
} from './sanitization/bypass';
|
||||
|
||||
export {
|
||||
getLContext as ɵgetLContext
|
||||
} from './render3/context_discovery';
|
||||
|
||||
export {
|
||||
NG_ELEMENT_ID as ɵNG_ELEMENT_ID,
|
||||
NG_COMP_DEF as ɵNG_COMP_DEF,
|
||||
NG_DIR_DEF as ɵNG_DIR_DEF,
|
||||
NG_PIPE_DEF as ɵNG_PIPE_DEF,
|
||||
NG_MOD_DEF as ɵNG_MOD_DEF,
|
||||
} from './render3/fields';
|
||||
|
||||
export {
|
||||
NG_PROV_DEF as ɵNG_PROV_DEF,
|
||||
NG_INJ_DEF as ɵNG_INJ_DEF,
|
||||
} from './di/interface/defs';
|
||||
|
||||
export {
|
||||
Player as ɵPlayer,
|
||||
PlayerFactory as ɵPlayerFactory,
|
||||
PlayState as ɵPlayState,
|
||||
PlayerHandler as ɵPlayerHandler,
|
||||
} from './render3/interfaces/player';
|
||||
|
||||
export {
|
||||
LContext as ɵLContext,
|
||||
} from './render3/interfaces/context';
|
||||
|
||||
export {
|
||||
setDocument as ɵsetDocument
|
||||
} from './render3/interfaces/document';
|
||||
|
||||
// we reexport these symbols just so that they are retained during the dead code elimination
|
||||
// performed by rollup while it's creating fesm files.
|
||||
//
|
||||
// no code actually imports these symbols from the @angular/core entry point
|
||||
export {
|
||||
compileNgModuleFactory__POST_R3__ as ɵcompileNgModuleFactory__POST_R3__,
|
||||
isBoundToModule__POST_R3__ as ɵisBoundToModule__POST_R3__
|
||||
} from './application_ref';
|
||||
export {
|
||||
SWITCH_COMPILE_COMPONENT__POST_R3__ as ɵSWITCH_COMPILE_COMPONENT__POST_R3__,
|
||||
SWITCH_COMPILE_DIRECTIVE__POST_R3__ as ɵSWITCH_COMPILE_DIRECTIVE__POST_R3__,
|
||||
SWITCH_COMPILE_PIPE__POST_R3__ as ɵSWITCH_COMPILE_PIPE__POST_R3__,
|
||||
} from './metadata/directives';
|
||||
export {
|
||||
SWITCH_COMPILE_NGMODULE__POST_R3__ as ɵSWITCH_COMPILE_NGMODULE__POST_R3__,
|
||||
} from './metadata/ng_module';
|
||||
export {
|
||||
getDebugNode__POST_R3__ as ɵgetDebugNode__POST_R3__,
|
||||
} from './debug/debug_node';
|
||||
export {
|
||||
SWITCH_COMPILE_INJECTABLE__POST_R3__ as ɵSWITCH_COMPILE_INJECTABLE__POST_R3__,
|
||||
} from './di/injectable';
|
||||
export {
|
||||
SWITCH_IVY_ENABLED__POST_R3__ as ɵSWITCH_IVY_ENABLED__POST_R3__,
|
||||
} from './ivy_switch';
|
||||
export {
|
||||
SWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__ as ɵSWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__,
|
||||
} from './change_detection/change_detector_ref';
|
||||
export {
|
||||
Compiler_compileModuleSync__POST_R3__ as ɵCompiler_compileModuleSync__POST_R3__,
|
||||
Compiler_compileModuleAsync__POST_R3__ as ɵCompiler_compileModuleAsync__POST_R3__,
|
||||
Compiler_compileModuleAndAllComponentsSync__POST_R3__ as ɵCompiler_compileModuleAndAllComponentsSync__POST_R3__,
|
||||
Compiler_compileModuleAndAllComponentsAsync__POST_R3__ as ɵCompiler_compileModuleAndAllComponentsAsync__POST_R3__,
|
||||
} from './linker/compiler';
|
||||
export {
|
||||
SWITCH_ELEMENT_REF_FACTORY__POST_R3__ as ɵSWITCH_ELEMENT_REF_FACTORY__POST_R3__,
|
||||
} from './linker/element_ref';
|
||||
export {
|
||||
SWITCH_TEMPLATE_REF_FACTORY__POST_R3__ as ɵSWITCH_TEMPLATE_REF_FACTORY__POST_R3__,
|
||||
} from './linker/template_ref';
|
||||
export {
|
||||
SWITCH_VIEW_CONTAINER_REF_FACTORY__POST_R3__ as ɵSWITCH_VIEW_CONTAINER_REF_FACTORY__POST_R3__,
|
||||
} from './linker/view_container_ref';
|
||||
export {
|
||||
SWITCH_RENDERER2_FACTORY__POST_R3__ as ɵSWITCH_RENDERER2_FACTORY__POST_R3__,
|
||||
} from './render/api';
|
||||
|
||||
export { getModuleFactory__POST_R3__ as ɵgetModuleFactory__POST_R3__ } from './linker/ng_module_factory_loader';
|
||||
|
||||
export { registerNgModuleType as ɵregisterNgModuleType } from './linker/ng_module_factory_registration';
|
||||
|
||||
export {
|
||||
publishGlobalUtil as ɵpublishGlobalUtil,
|
||||
publishDefaultGlobalUtils as ɵpublishDefaultGlobalUtils
|
||||
} from './render3/util/global_utils';
|
||||
|
||||
export {createInjector as ɵcreateInjector} from './di/r3_injector';
|
||||
|
||||
export {INJECTOR_IMPL__POST_R3__ as ɵINJECTOR_IMPL__POST_R3__} from './di/injector';
|
||||
|
||||
// clang-format on
|
||||
|
@ -10,7 +10,7 @@ import {Injector} from '../di';
|
||||
import {CONTAINER_HEADER_OFFSET, LContainer, NATIVE} from '../render3/interfaces/container';
|
||||
import {TElementNode, TNode, TNodeFlags, TNodeType} from '../render3/interfaces/node';
|
||||
import {isComponentHost, isLContainer} from '../render3/interfaces/type_checks';
|
||||
import {DECLARATION_COMPONENT_VIEW, LView, PARENT, TData, TVIEW, T_HOST} from '../render3/interfaces/view';
|
||||
import {DECLARATION_COMPONENT_VIEW, LView, PARENT, T_HOST, TData, TVIEW} from '../render3/interfaces/view';
|
||||
import {getComponent, getContext, getInjectionTokens, getInjector, getListeners, getLocalRefs, getOwningComponent, loadLContext} from '../render3/util/discovery_utils';
|
||||
import {INTERPOLATION_DELIMITER, renderStringify} from '../render3/util/misc_utils';
|
||||
import {getComponentLViewByIndex, getNativeByTNodeOrNull} from '../render3/util/view_utils';
|
||||
@ -53,15 +53,25 @@ export class DebugNode__PRE_R3__ {
|
||||
}
|
||||
}
|
||||
|
||||
get injector(): Injector { return this._debugContext.injector; }
|
||||
get injector(): Injector {
|
||||
return this._debugContext.injector;
|
||||
}
|
||||
|
||||
get componentInstance(): any { return this._debugContext.component; }
|
||||
get componentInstance(): any {
|
||||
return this._debugContext.component;
|
||||
}
|
||||
|
||||
get context(): any { return this._debugContext.context; }
|
||||
get context(): any {
|
||||
return this._debugContext.context;
|
||||
}
|
||||
|
||||
get references(): {[key: string]: any} { return this._debugContext.references; }
|
||||
get references(): {[key: string]: any} {
|
||||
return this._debugContext.references;
|
||||
}
|
||||
|
||||
get providerTokens(): any[] { return this._debugContext.providerTokens; }
|
||||
get providerTokens(): any[] {
|
||||
return this._debugContext.providerTokens;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,9 +80,9 @@ export class DebugNode__PRE_R3__ {
|
||||
export interface DebugElement extends DebugNode {
|
||||
readonly name: string;
|
||||
readonly properties: {[key: string]: any};
|
||||
readonly attributes: {[key: string]: string | null};
|
||||
readonly attributes: {[key: string]: string|null};
|
||||
readonly classes: {[key: string]: boolean};
|
||||
readonly styles: {[key: string]: string | null};
|
||||
readonly styles: {[key: string]: string|null};
|
||||
readonly childNodes: DebugNode[];
|
||||
readonly nativeElement: any;
|
||||
readonly children: DebugElement[];
|
||||
@ -83,11 +93,11 @@ export interface DebugElement extends DebugNode {
|
||||
triggerEventHandler(eventName: string, eventObj: any): void;
|
||||
}
|
||||
export class DebugElement__PRE_R3__ extends DebugNode__PRE_R3__ implements DebugElement {
|
||||
readonly name !: string;
|
||||
readonly name!: string;
|
||||
readonly properties: {[key: string]: any} = {};
|
||||
readonly attributes: {[key: string]: string | null} = {};
|
||||
readonly attributes: {[key: string]: string|null} = {};
|
||||
readonly classes: {[key: string]: boolean} = {};
|
||||
readonly styles: {[key: string]: string | null} = {};
|
||||
readonly styles: {[key: string]: string|null} = {};
|
||||
readonly childNodes: DebugNode[] = [];
|
||||
readonly nativeElement: any;
|
||||
|
||||
@ -99,14 +109,14 @@ export class DebugElement__PRE_R3__ extends DebugNode__PRE_R3__ implements Debug
|
||||
addChild(child: DebugNode) {
|
||||
if (child) {
|
||||
this.childNodes.push(child);
|
||||
(child as{parent: DebugNode}).parent = this;
|
||||
(child as {parent: DebugNode}).parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
removeChild(child: DebugNode) {
|
||||
const childIndex = this.childNodes.indexOf(child);
|
||||
if (childIndex !== -1) {
|
||||
(child as{parent: DebugNode | null}).parent = null;
|
||||
(child as {parent: DebugNode | null}).parent = null;
|
||||
this.childNodes.splice(childIndex, 1);
|
||||
}
|
||||
}
|
||||
@ -119,7 +129,7 @@ export class DebugElement__PRE_R3__ extends DebugNode__PRE_R3__ implements Debug
|
||||
if (c.parent) {
|
||||
(c.parent as DebugElement__PRE_R3__).removeChild(c);
|
||||
}
|
||||
(child as{parent: DebugNode}).parent = this;
|
||||
(child as {parent: DebugNode}).parent = this;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -132,7 +142,7 @@ export class DebugElement__PRE_R3__ extends DebugNode__PRE_R3__ implements Debug
|
||||
if (newChild.parent) {
|
||||
(newChild.parent as DebugElement__PRE_R3__).removeChild(newChild);
|
||||
}
|
||||
(newChild as{parent: DebugNode}).parent = this;
|
||||
(newChild as {parent: DebugNode}).parent = this;
|
||||
this.childNodes.splice(refIndex, 0, newChild);
|
||||
}
|
||||
}
|
||||
@ -155,9 +165,8 @@ export class DebugElement__PRE_R3__ extends DebugNode__PRE_R3__ implements Debug
|
||||
}
|
||||
|
||||
get children(): DebugElement[] {
|
||||
return this
|
||||
.childNodes //
|
||||
.filter((node) => node instanceof DebugElement__PRE_R3__) as DebugElement[];
|
||||
return this.childNodes //
|
||||
.filter((node) => node instanceof DebugElement__PRE_R3__) as DebugElement[];
|
||||
}
|
||||
|
||||
triggerEventHandler(eventName: string, eventObj: any) {
|
||||
@ -205,14 +214,18 @@ function _queryNodeChildren(
|
||||
class DebugNode__POST_R3__ implements DebugNode {
|
||||
readonly nativeNode: Node;
|
||||
|
||||
constructor(nativeNode: Node) { this.nativeNode = nativeNode; }
|
||||
constructor(nativeNode: Node) {
|
||||
this.nativeNode = nativeNode;
|
||||
}
|
||||
|
||||
get parent(): DebugElement|null {
|
||||
const parent = this.nativeNode.parentNode as Element;
|
||||
return parent ? new DebugElement__POST_R3__(parent) : null;
|
||||
}
|
||||
|
||||
get injector(): Injector { return getInjector(this.nativeNode); }
|
||||
get injector(): Injector {
|
||||
return getInjector(this.nativeNode);
|
||||
}
|
||||
|
||||
get componentInstance(): any {
|
||||
const nativeElement = this.nativeNode;
|
||||
@ -227,9 +240,13 @@ class DebugNode__POST_R3__ implements DebugNode {
|
||||
return getListeners(this.nativeNode as Element).filter(listener => listener.type === 'dom');
|
||||
}
|
||||
|
||||
get references(): {[key: string]: any;} { return getLocalRefs(this.nativeNode); }
|
||||
get references(): {[key: string]: any;} {
|
||||
return getLocalRefs(this.nativeNode);
|
||||
}
|
||||
|
||||
get providerTokens(): any[] { return getInjectionTokens(this.nativeNode as Element); }
|
||||
get providerTokens(): any[] {
|
||||
return getInjectionTokens(this.nativeNode as Element);
|
||||
}
|
||||
}
|
||||
|
||||
class DebugElement__POST_R3__ extends DebugNode__POST_R3__ implements DebugElement {
|
||||
@ -244,11 +261,11 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ implements DebugEleme
|
||||
|
||||
get name(): string {
|
||||
try {
|
||||
const context = loadLContext(this.nativeNode) !;
|
||||
const context = loadLContext(this.nativeNode)!;
|
||||
const lView = context.lView;
|
||||
const tData = lView[TVIEW].data;
|
||||
const tNode = tData[context.nodeIndex] as TNode;
|
||||
return tNode.tagName !;
|
||||
return tNode.tagName!;
|
||||
} catch (e) {
|
||||
return this.nativeNode.nodeName;
|
||||
}
|
||||
@ -285,8 +302,8 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ implements DebugEleme
|
||||
return properties;
|
||||
}
|
||||
|
||||
get attributes(): {[key: string]: string | null;} {
|
||||
const attributes: {[key: string]: string | null;} = {};
|
||||
get attributes(): {[key: string]: string|null;} {
|
||||
const attributes: {[key: string]: string|null;} = {};
|
||||
const element = this.nativeElement;
|
||||
|
||||
if (!element) {
|
||||
@ -343,9 +360,9 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ implements DebugEleme
|
||||
return attributes;
|
||||
}
|
||||
|
||||
get styles(): {[key: string]: string | null} {
|
||||
get styles(): {[key: string]: string|null} {
|
||||
if (this.nativeElement && (this.nativeElement as HTMLElement).style) {
|
||||
return (this.nativeElement as HTMLElement).style as{[key: string]: any};
|
||||
return (this.nativeElement as HTMLElement).style as {[key: string]: any};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@ -438,7 +455,7 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ implements DebugEleme
|
||||
}
|
||||
}
|
||||
|
||||
function copyDomProperties(element: Element | null, properties: {[name: string]: string}): void {
|
||||
function copyDomProperties(element: Element|null, properties: {[name: string]: string}): void {
|
||||
if (element) {
|
||||
// Skip own properties (as those are patched)
|
||||
let obj = Object.getPrototypeOf(element);
|
||||
@ -481,8 +498,8 @@ function _queryAllR3(
|
||||
parentElement: DebugElement, predicate: Predicate<DebugNode>, matches: DebugNode[],
|
||||
elementsOnly: false): void;
|
||||
function _queryAllR3(
|
||||
parentElement: DebugElement, predicate: Predicate<DebugElement>| Predicate<DebugNode>,
|
||||
matches: DebugElement[] | DebugNode[], elementsOnly: boolean) {
|
||||
parentElement: DebugElement, predicate: Predicate<DebugElement>|Predicate<DebugNode>,
|
||||
matches: DebugElement[]|DebugNode[], elementsOnly: boolean) {
|
||||
const context = loadLContext(parentElement.nativeNode, false);
|
||||
if (context !== null) {
|
||||
const parentTNode = context.lView[TVIEW].data[context.nodeIndex] as TNode;
|
||||
@ -506,8 +523,8 @@ function _queryAllR3(
|
||||
* @param rootNativeNode the root native node on which predicate should not be matched
|
||||
*/
|
||||
function _queryNodeChildrenR3(
|
||||
tNode: TNode, lView: LView, predicate: Predicate<DebugElement>| Predicate<DebugNode>,
|
||||
matches: DebugElement[] | DebugNode[], elementsOnly: boolean, rootNativeNode: any) {
|
||||
tNode: TNode, lView: LView, predicate: Predicate<DebugElement>|Predicate<DebugNode>,
|
||||
matches: DebugElement[]|DebugNode[], elementsOnly: boolean, rootNativeNode: any) {
|
||||
const nativeNode = getNativeByTNodeOrNull(tNode, lView);
|
||||
// For each type of TNode, specific logic is executed.
|
||||
if (tNode.type === TNodeType.Element || tNode.type === TNodeType.ElementContainer) {
|
||||
@ -520,7 +537,7 @@ function _queryNodeChildrenR3(
|
||||
const componentView = getComponentLViewByIndex(tNode.index, lView);
|
||||
if (componentView && componentView[TVIEW].firstChild) {
|
||||
_queryNodeChildrenR3(
|
||||
componentView[TVIEW].firstChild !, componentView, predicate, matches, elementsOnly,
|
||||
componentView[TVIEW].firstChild!, componentView, predicate, matches, elementsOnly,
|
||||
rootNativeNode);
|
||||
}
|
||||
} else {
|
||||
@ -556,17 +573,17 @@ function _queryNodeChildrenR3(
|
||||
} else if (tNode.type === TNodeType.Projection) {
|
||||
// Case 3: the TNode is a projection insertion point (i.e. a <ng-content>).
|
||||
// The nodes projected at this location all need to be processed.
|
||||
const componentView = lView ![DECLARATION_COMPONENT_VIEW];
|
||||
const componentView = lView![DECLARATION_COMPONENT_VIEW];
|
||||
const componentHost = componentView[T_HOST] as TElementNode;
|
||||
const head: TNode|null =
|
||||
(componentHost.projection as(TNode | null)[])[tNode.projection as number];
|
||||
(componentHost.projection as (TNode | null)[])[tNode.projection as number];
|
||||
|
||||
if (Array.isArray(head)) {
|
||||
for (let nativeNode of head) {
|
||||
_addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
|
||||
}
|
||||
} else if (head) {
|
||||
const nextLView = componentView[PARENT] !as LView;
|
||||
const nextLView = componentView[PARENT]! as LView;
|
||||
const nextTNode = nextLView[TVIEW].data[head.index] as TNode;
|
||||
_queryNodeChildrenR3(nextTNode, nextLView, predicate, matches, elementsOnly, rootNativeNode);
|
||||
}
|
||||
@ -596,12 +613,12 @@ function _queryNodeChildrenR3(
|
||||
* @param rootNativeNode the root native node on which predicate should not be matched
|
||||
*/
|
||||
function _queryNodeChildrenInContainerR3(
|
||||
lContainer: LContainer, predicate: Predicate<DebugElement>| Predicate<DebugNode>,
|
||||
matches: DebugElement[] | DebugNode[], elementsOnly: boolean, rootNativeNode: any) {
|
||||
lContainer: LContainer, predicate: Predicate<DebugElement>|Predicate<DebugNode>,
|
||||
matches: DebugElement[]|DebugNode[], elementsOnly: boolean, rootNativeNode: any) {
|
||||
for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) {
|
||||
const childView = lContainer[i];
|
||||
_queryNodeChildrenR3(
|
||||
childView[TVIEW].node !, childView, predicate, matches, elementsOnly, rootNativeNode);
|
||||
childView[TVIEW].node!, childView, predicate, matches, elementsOnly, rootNativeNode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -615,8 +632,8 @@ function _queryNodeChildrenInContainerR3(
|
||||
* @param rootNativeNode the root native node on which predicate should not be matched
|
||||
*/
|
||||
function _addQueryMatchR3(
|
||||
nativeNode: any, predicate: Predicate<DebugElement>| Predicate<DebugNode>,
|
||||
matches: DebugElement[] | DebugNode[], elementsOnly: boolean, rootNativeNode: any) {
|
||||
nativeNode: any, predicate: Predicate<DebugElement>|Predicate<DebugNode>,
|
||||
matches: DebugElement[]|DebugNode[], elementsOnly: boolean, rootNativeNode: any) {
|
||||
if (rootNativeNode !== nativeNode) {
|
||||
const debugNode = getDebugNode(nativeNode);
|
||||
if (!debugNode) {
|
||||
@ -645,8 +662,8 @@ function _addQueryMatchR3(
|
||||
* @param elementsOnly whether only elements should be searched
|
||||
*/
|
||||
function _queryNativeNodeDescendants(
|
||||
parentNode: any, predicate: Predicate<DebugElement>| Predicate<DebugNode>,
|
||||
matches: DebugElement[] | DebugNode[], elementsOnly: boolean) {
|
||||
parentNode: any, predicate: Predicate<DebugElement>|Predicate<DebugNode>,
|
||||
matches: DebugElement[]|DebugNode[], elementsOnly: boolean) {
|
||||
const nodes = parentNode.childNodes;
|
||||
const length = nodes.length;
|
||||
|
||||
@ -757,7 +774,9 @@ export function removeDebugNodeFromIndex(node: DebugNode) {
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface Predicate<T> { (value: T): boolean; }
|
||||
export interface Predicate<T> {
|
||||
(value: T): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
|
@ -21,7 +21,9 @@ import {stringify} from '../util/stringify';
|
||||
* {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref_fn'}
|
||||
* @publicApi
|
||||
*/
|
||||
export interface ForwardRefFn { (): any; }
|
||||
export interface ForwardRefFn {
|
||||
(): any;
|
||||
}
|
||||
|
||||
const __forward_ref__ = getClosureSafeProperty({__forward_ref__: getClosureSafeProperty});
|
||||
|
||||
@ -39,7 +41,9 @@ const __forward_ref__ = getClosureSafeProperty({__forward_ref__: getClosureSafeP
|
||||
*/
|
||||
export function forwardRef(forwardRefFn: ForwardRefFn): Type<any> {
|
||||
(<any>forwardRefFn).__forward_ref__ = forwardRef;
|
||||
(<any>forwardRefFn).toString = function() { return stringify(this()); };
|
||||
(<any>forwardRefFn).toString = function() {
|
||||
return stringify(this());
|
||||
};
|
||||
return (<Type<any>><any>forwardRefFn);
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
import {Type} from '../interface/type';
|
||||
import {TypeDecorator, makeDecorator} from '../util/decorators';
|
||||
import {makeDecorator, TypeDecorator} from '../util/decorators';
|
||||
|
||||
import {InjectableType, getInjectableDef, ɵɵdefineInjectable} from './interface/defs';
|
||||
import {getInjectableDef, InjectableType, ɵɵdefineInjectable} from './interface/defs';
|
||||
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueSansProvider} from './interface/provider';
|
||||
import {compileInjectable as render3CompileInjectable} from './jit/injectable';
|
||||
import {convertInjectableProviderToFactory} from './util';
|
||||
@ -21,8 +21,8 @@ import {convertInjectableProviderToFactory} from './util';
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export type InjectableProvider = ValueSansProvider | ExistingSansProvider |
|
||||
StaticClassSansProvider | ConstructorSansProvider | FactorySansProvider | ClassSansProvider;
|
||||
export type InjectableProvider = ValueSansProvider|ExistingSansProvider|StaticClassSansProvider|
|
||||
ConstructorSansProvider|FactorySansProvider|ClassSansProvider;
|
||||
|
||||
/**
|
||||
* Type of the Injectable decorator / constructor function.
|
||||
@ -50,11 +50,11 @@ export interface InjectableDecorator {
|
||||
*
|
||||
*/
|
||||
(): TypeDecorator;
|
||||
(options?: {providedIn: Type<any>| 'root' | 'platform' | 'any' | null}&
|
||||
(options?: {providedIn: Type<any>|'root'|'platform'|'any'|null}&
|
||||
InjectableProvider): TypeDecorator;
|
||||
new (): Injectable;
|
||||
new (options?: {providedIn: Type<any>| 'root' | 'platform' | 'any' | null}&
|
||||
InjectableProvider): Injectable;
|
||||
new(): Injectable;
|
||||
new(options?: {providedIn: Type<any>|'root'|'platform'|'any'|null}&
|
||||
InjectableProvider): Injectable;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,9 +91,9 @@ export const Injectable: InjectableDecorator = makeDecorator(
|
||||
/**
|
||||
* Supports @Injectable() in JIT mode for Render2.
|
||||
*/
|
||||
function render2CompileInjectable(injectableType: Type<any>, options?: {
|
||||
providedIn?: Type<any>| 'root' | 'platform' | 'any' | null
|
||||
} & InjectableProvider): void {
|
||||
function render2CompileInjectable(
|
||||
injectableType: Type<any>,
|
||||
options?: {providedIn?: Type<any>|'root'|'platform'|'any'|null}&InjectableProvider): void {
|
||||
if (options && options.providedIn !== undefined && !getInjectableDef(injectableType)) {
|
||||
(injectableType as InjectableType<any>).ɵprov = ɵɵdefineInjectable({
|
||||
token: injectableType,
|
||||
|
@ -57,8 +57,7 @@ export class InjectionToken<T> {
|
||||
readonly ɵprov: never|undefined;
|
||||
|
||||
constructor(protected _desc: string, options?: {
|
||||
providedIn?: Type<any>| 'root' | 'platform' | 'any' | null,
|
||||
factory: () => T
|
||||
providedIn?: Type<any>|'root'|'platform'|'any'|null, factory: () => T
|
||||
}) {
|
||||
this.ɵprov = undefined;
|
||||
if (typeof options == 'number') {
|
||||
@ -75,7 +74,11 @@ export class InjectionToken<T> {
|
||||
}
|
||||
}
|
||||
|
||||
toString(): string { return `InjectionToken ${this._desc}`; }
|
||||
toString(): string {
|
||||
return `InjectionToken ${this._desc}`;
|
||||
}
|
||||
}
|
||||
|
||||
export interface InjectableDefToken<T> extends InjectionToken<T> { ɵprov: never; }
|
||||
export interface InjectableDefToken<T> extends InjectionToken<T> {
|
||||
ɵprov: never;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import {stringify} from '../util/stringify';
|
||||
|
||||
import {resolveForwardRef} from './forward_ref';
|
||||
import {InjectionToken} from './injection_token';
|
||||
import {INJECTOR, NG_TEMP_TOKEN_PATH, NullInjector, THROW_IF_NOT_FOUND, USE_VALUE, catchInjectorError, formatError, setCurrentInjector, ɵɵinject} from './injector_compatibility';
|
||||
import {catchInjectorError, formatError, INJECTOR, NG_TEMP_TOKEN_PATH, NullInjector, setCurrentInjector, THROW_IF_NOT_FOUND, USE_VALUE, ɵɵinject} from './injector_compatibility';
|
||||
import {getInjectableDef, ɵɵdefineInjectable} from './interface/defs';
|
||||
import {InjectFlags} from './interface/injector';
|
||||
import {ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, StaticProvider, ValueProvider} from './interface/provider';
|
||||
@ -20,12 +20,12 @@ import {createInjector} from './r3_injector';
|
||||
import {INJECTOR_SCOPE} from './scope';
|
||||
|
||||
export function INJECTOR_IMPL__PRE_R3__(
|
||||
providers: StaticProvider[], parent: Injector | undefined, name: string) {
|
||||
providers: StaticProvider[], parent: Injector|undefined, name: string) {
|
||||
return new StaticInjector(providers, parent, name);
|
||||
}
|
||||
|
||||
export function INJECTOR_IMPL__POST_R3__(
|
||||
providers: StaticProvider[], parent: Injector | undefined, name: string) {
|
||||
providers: StaticProvider[], parent: Injector|undefined, name: string) {
|
||||
return createInjector({name: name}, parent, providers, name);
|
||||
}
|
||||
|
||||
@ -166,8 +166,9 @@ export class StaticInjector implements Injector {
|
||||
const providedIn = injectableDef && injectableDef.providedIn;
|
||||
if (providedIn === 'any' || providedIn != null && providedIn === this.scope) {
|
||||
records.set(
|
||||
token, record = resolveProvider(
|
||||
{provide: token, useFactory: injectableDef.factory, deps: EMPTY}));
|
||||
token,
|
||||
record = resolveProvider(
|
||||
{provide: token, useFactory: injectableDef.factory, deps: EMPTY}));
|
||||
}
|
||||
}
|
||||
if (record === undefined) {
|
||||
@ -193,7 +194,7 @@ export class StaticInjector implements Injector {
|
||||
}
|
||||
|
||||
type SupportedProvider =
|
||||
ValueProvider | ExistingProvider | StaticClassProvider | ConstructorProvider | FactoryProvider;
|
||||
ValueProvider|ExistingProvider|StaticClassProvider|ConstructorProvider|FactoryProvider;
|
||||
|
||||
interface Record {
|
||||
fn: Function;
|
||||
@ -293,7 +294,7 @@ function recursivelyProcessProviders(records: Map<any, Record>, provider: Static
|
||||
}
|
||||
|
||||
function tryResolveToken(
|
||||
token: any, record: Record | undefined | null, records: Map<any, Record|null>, parent: Injector,
|
||||
token: any, record: Record|undefined|null, records: Map<any, Record|null>, parent: Injector,
|
||||
notFoundValue: any, flags: InjectFlags): any {
|
||||
try {
|
||||
return resolveToken(token, record, records, parent, notFoundValue, flags);
|
||||
@ -313,7 +314,7 @@ function tryResolveToken(
|
||||
}
|
||||
|
||||
function resolveToken(
|
||||
token: any, record: Record | undefined | null, records: Map<any, Record|null>, parent: Injector,
|
||||
token: any, record: Record|undefined|null, records: Map<any, Record|null>, parent: Injector,
|
||||
notFoundValue: any, flags: InjectFlags): any {
|
||||
let value;
|
||||
if (record && !(flags & InjectFlags.SkipSelf)) {
|
||||
|
@ -33,7 +33,7 @@ import {Inject, Optional, Self, SkipSelf} from './metadata';
|
||||
export const INJECTOR = new InjectionToken<Injector>(
|
||||
'INJECTOR',
|
||||
-1 as any // `-1` is used by Ivy DI system as special value to recognize it as `Injector`.
|
||||
);
|
||||
);
|
||||
|
||||
const _THROW_IF_NOT_FOUND = {};
|
||||
export const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
||||
@ -55,7 +55,7 @@ export const USE_VALUE =
|
||||
*/
|
||||
let _currentInjector: Injector|undefined|null = undefined;
|
||||
|
||||
export function setCurrentInjector(injector: Injector | null | undefined): Injector|undefined|null {
|
||||
export function setCurrentInjector(injector: Injector|null|undefined): Injector|undefined|null {
|
||||
const former = _currentInjector;
|
||||
_currentInjector = injector;
|
||||
return former;
|
||||
@ -70,25 +70,25 @@ export function setCurrentInjector(injector: Injector | null | undefined): Injec
|
||||
* 1. `Injector` should not depend on ivy logic.
|
||||
* 2. To maintain tree shake-ability we don't want to bring in unnecessary code.
|
||||
*/
|
||||
let _injectImplementation:
|
||||
(<T>(token: Type<T>| InjectionToken<T>, flags?: InjectFlags) => T | null)|undefined;
|
||||
let _injectImplementation: (<T>(token: Type<T>|InjectionToken<T>, flags?: InjectFlags) => T | null)|
|
||||
undefined;
|
||||
|
||||
/**
|
||||
* Sets the current inject implementation.
|
||||
*/
|
||||
export function setInjectImplementation(
|
||||
impl: (<T>(token: Type<T>| InjectionToken<T>, flags?: InjectFlags) => T | null) | undefined):
|
||||
(<T>(token: Type<T>| InjectionToken<T>, flags?: InjectFlags) => T | null)|undefined {
|
||||
impl: (<T>(token: Type<T>|InjectionToken<T>, flags?: InjectFlags) => T | null)|
|
||||
undefined): (<T>(token: Type<T>|InjectionToken<T>, flags?: InjectFlags) => T | null)|undefined {
|
||||
const previous = _injectImplementation;
|
||||
_injectImplementation = impl;
|
||||
return previous;
|
||||
}
|
||||
|
||||
export function injectInjectorOnly<T>(token: Type<T>| InjectionToken<T>): T;
|
||||
export function injectInjectorOnly<T>(token: Type<T>| InjectionToken<T>, flags?: InjectFlags): T|
|
||||
export function injectInjectorOnly<T>(token: Type<T>|InjectionToken<T>): T;
|
||||
export function injectInjectorOnly<T>(token: Type<T>|InjectionToken<T>, flags?: InjectFlags): T|
|
||||
null;
|
||||
export function injectInjectorOnly<T>(
|
||||
token: Type<T>| InjectionToken<T>, flags = InjectFlags.Default): T|null {
|
||||
token: Type<T>|InjectionToken<T>, flags = InjectFlags.Default): T|null {
|
||||
if (_currentInjector === undefined) {
|
||||
throw new Error(`inject() must be called from an injection context`);
|
||||
} else if (_currentInjector === null) {
|
||||
@ -104,15 +104,15 @@ export function injectInjectorOnly<T>(
|
||||
* Must be used in the context of a factory function such as one defined for an
|
||||
* `InjectionToken`. Throws an error if not called from such a context.
|
||||
*
|
||||
* (Additional documentation moved to `inject`, as it is the public API, and an alias for this instruction)
|
||||
* (Additional documentation moved to `inject`, as it is the public API, and an alias for this
|
||||
* instruction)
|
||||
*
|
||||
* @see inject
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinject<T>(token: Type<T>| InjectionToken<T>): T;
|
||||
export function ɵɵinject<T>(token: Type<T>| InjectionToken<T>, flags?: InjectFlags): T|null;
|
||||
export function ɵɵinject<T>(token: Type<T>| InjectionToken<T>, flags = InjectFlags.Default): T|
|
||||
null {
|
||||
export function ɵɵinject<T>(token: Type<T>|InjectionToken<T>): T;
|
||||
export function ɵɵinject<T>(token: Type<T>|InjectionToken<T>, flags?: InjectFlags): T|null;
|
||||
export function ɵɵinject<T>(token: Type<T>|InjectionToken<T>, flags = InjectFlags.Default): T|null {
|
||||
return (_injectImplementation || injectInjectorOnly)(resolveForwardRef(token), flags);
|
||||
}
|
||||
|
||||
@ -130,10 +130,12 @@ export function ɵɵinject<T>(token: Type<T>| InjectionToken<T>, flags = InjectF
|
||||
*/
|
||||
export function ɵɵinvalidFactoryDep(index: number): never {
|
||||
const msg = ngDevMode ?
|
||||
`This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
|
||||
`This constructor is not compatible with Angular Dependency Injection because its dependency at index ${
|
||||
index} of the parameter list is invalid.
|
||||
This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.
|
||||
|
||||
Please check that 1) the type for the parameter at index ${index} is correct and 2) the correct Angular decorators are defined for this class and its ancestors.` :
|
||||
Please check that 1) the type for the parameter at index ${
|
||||
index} is correct and 2) the correct Angular decorators are defined for this class and its ancestors.` :
|
||||
'invalid';
|
||||
throw new Error(msg);
|
||||
}
|
||||
@ -172,7 +174,7 @@ export const inject = ɵɵinject;
|
||||
* `InjectableDef`.
|
||||
*/
|
||||
export function injectRootLimpMode<T>(
|
||||
token: Type<T>| InjectionToken<T>, notFoundValue: T | undefined, flags: InjectFlags): T|null {
|
||||
token: Type<T>|InjectionToken<T>, notFoundValue: T|undefined, flags: InjectFlags): T|null {
|
||||
const injectableDef: ɵɵInjectableDef<T>|null = getInjectableDef(token);
|
||||
if (injectableDef && injectableDef.providedIn == 'root') {
|
||||
return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() :
|
||||
@ -183,7 +185,7 @@ export function injectRootLimpMode<T>(
|
||||
throw new Error(`Injector: NOT_FOUND [${stringify(token)}]`);
|
||||
}
|
||||
|
||||
export function injectArgs(types: (Type<any>| InjectionToken<any>| any[])[]): any[] {
|
||||
export function injectArgs(types: (Type<any>|InjectionToken<any>|any[])[]): any[] {
|
||||
const args: any[] = [];
|
||||
for (let i = 0; i < types.length; i++) {
|
||||
const arg = resolveForwardRef(types[i]);
|
||||
@ -210,7 +212,7 @@ export function injectArgs(types: (Type<any>| InjectionToken<any>| any[])[]): an
|
||||
}
|
||||
}
|
||||
|
||||
args.push(ɵɵinject(type !, flags));
|
||||
args.push(ɵɵinject(type!, flags));
|
||||
} else {
|
||||
args.push(ɵɵinject(arg));
|
||||
}
|
||||
@ -236,7 +238,7 @@ export class NullInjector implements Injector {
|
||||
|
||||
|
||||
export function catchInjectorError(
|
||||
e: any, token: any, injectorErrorName: string, source: string | null): never {
|
||||
e: any, token: any, injectorErrorName: string, source: string|null): never {
|
||||
const tokenPath: any[] = e[NG_TEMP_TOKEN_PATH];
|
||||
if (token[SOURCE]) {
|
||||
tokenPath.unshift(token[SOURCE]);
|
||||
@ -248,7 +250,7 @@ export function catchInjectorError(
|
||||
}
|
||||
|
||||
export function formatError(
|
||||
text: string, obj: any, injectorErrorName: string, source: string | null = null): string {
|
||||
text: string, obj: any, injectorErrorName: string, source: string|null = null): string {
|
||||
text = text && text.charAt(0) === '\n' && text.charAt(1) == NO_NEW_LINE ? text.substr(2) : text;
|
||||
let context = stringify(obj);
|
||||
if (Array.isArray(obj)) {
|
||||
@ -264,5 +266,6 @@ export function formatError(
|
||||
}
|
||||
context = `{${parts.join(', ')}}`;
|
||||
}
|
||||
return `${injectorErrorName}${source ? '(' + source + ')' : ''}[${context}]: ${text.replace(NEW_LINE, '\n ')}`;
|
||||
return `${injectorErrorName}${source ? '(' + source + ')' : ''}[${context}]: ${
|
||||
text.replace(NEW_LINE, '\n ')}`;
|
||||
}
|
||||
|
@ -140,13 +140,14 @@ export interface InjectorTypeWithProviders<T> {
|
||||
*/
|
||||
export function ɵɵdefineInjectable<T>(opts: {
|
||||
token: unknown,
|
||||
providedIn?: Type<any>| 'root' | 'platform' | 'any' | null,
|
||||
factory: () => T,
|
||||
providedIn?: Type<any>|'root'|'platform'|'any'|null, factory: () => T,
|
||||
}): never {
|
||||
return ({
|
||||
token: opts.token, providedIn: opts.providedIn as any || null, factory: opts.factory,
|
||||
value: undefined,
|
||||
} as ɵɵInjectableDef<T>) as never;
|
||||
token: opts.token,
|
||||
providedIn: opts.providedIn as any || null,
|
||||
factory: opts.factory,
|
||||
value: undefined,
|
||||
} as ɵɵInjectableDef<T>) as never;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,8 +180,10 @@ export const defineInjectable = ɵɵdefineInjectable;
|
||||
export function ɵɵdefineInjector(options: {factory: () => any, providers?: any[], imports?: any[]}):
|
||||
never {
|
||||
return ({
|
||||
factory: options.factory, providers: options.providers || [], imports: options.imports || [],
|
||||
} as ɵɵInjectorDef<any>) as never;
|
||||
factory: options.factory,
|
||||
providers: options.providers || [],
|
||||
imports: options.imports || [],
|
||||
} as ɵɵInjectorDef<any>) as never;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,15 +222,17 @@ function getOwnDefinition<T>(type: any, def: ɵɵInjectableDef<T>): ɵɵInjectab
|
||||
*/
|
||||
export function getInheritedInjectableDef<T>(type: any): ɵɵInjectableDef<T>|null {
|
||||
// See `jit/injectable.ts#compileInjectable` for context on NG_PROV_DEF_FALLBACK.
|
||||
const def = type && (type[NG_PROV_DEF] || type[NG_INJECTABLE_DEF] ||
|
||||
(type[NG_PROV_DEF_FALLBACK] && type[NG_PROV_DEF_FALLBACK]()));
|
||||
const def = type &&
|
||||
(type[NG_PROV_DEF] || type[NG_INJECTABLE_DEF] ||
|
||||
(type[NG_PROV_DEF_FALLBACK] && type[NG_PROV_DEF_FALLBACK]()));
|
||||
|
||||
if (def) {
|
||||
const typeName = getTypeName(type);
|
||||
// TODO(FW-1307): Re-add ngDevMode when closure can handle it
|
||||
// ngDevMode &&
|
||||
console.warn(
|
||||
`DEPRECATED: DI is instantiating a token "${typeName}" that inherits its @Injectable decorator but does not provide one itself.\n` +
|
||||
`DEPRECATED: DI is instantiating a token "${
|
||||
typeName}" that inherits its @Injectable decorator but does not provide one itself.\n` +
|
||||
`This will become an error in v10. Please add @Injectable() to the "${typeName}" class.`);
|
||||
return def;
|
||||
} else {
|
||||
|
@ -255,8 +255,8 @@ export interface FactoryProvider extends FactorySansProvider {
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export type StaticProvider = ValueProvider | ExistingProvider | StaticClassProvider |
|
||||
ConstructorProvider | FactoryProvider | any[];
|
||||
export type StaticProvider =
|
||||
ValueProvider|ExistingProvider|StaticClassProvider|ConstructorProvider|FactoryProvider|any[];
|
||||
|
||||
|
||||
/**
|
||||
@ -329,8 +329,8 @@ export interface ClassProvider extends ClassSansProvider {
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export type Provider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider |
|
||||
ExistingProvider | FactoryProvider | any[];
|
||||
export type Provider = TypeProvider|ValueProvider|ClassProvider|ConstructorProvider|
|
||||
ExistingProvider|FactoryProvider|any[];
|
||||
|
||||
/**
|
||||
* Describes a function that is used to process provider lists (such as provider
|
||||
|
@ -31,9 +31,9 @@ function getFactoryOf<T>(type: Type<any>): ((type?: Type<T>) => T)|null {
|
||||
|
||||
if (isForwardRef(type)) {
|
||||
return (() => {
|
||||
const factory = getFactoryOf<T>(resolveForwardRef(typeAny));
|
||||
return factory ? factory() : null;
|
||||
}) as any;
|
||||
const factory = getFactoryOf<T>(resolveForwardRef(typeAny));
|
||||
return factory ? factory() : null;
|
||||
}) as any;
|
||||
}
|
||||
|
||||
const def = getInjectableDef<T>(typeAny) || getInjectorDef<T>(typeAny);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {R3InjectableMetadataFacade, getCompilerFacade} from '../../compiler/compiler_facade';
|
||||
import {getCompilerFacade, R3InjectableMetadataFacade} from '../../compiler/compiler_facade';
|
||||
import {Type} from '../../interface/type';
|
||||
import {NG_FACTORY_DEF} from '../../render3/fields';
|
||||
import {getClosureSafeProperty} from '../../util/property';
|
||||
@ -76,7 +76,7 @@ export function compileInjectable(type: Type<any>, srcMeta?: Injectable): void {
|
||||
}
|
||||
}
|
||||
|
||||
type UseClassProvider = Injectable & ClassSansProvider & {deps?: any[]};
|
||||
type UseClassProvider = Injectable&ClassSansProvider&{deps?: any[]};
|
||||
|
||||
const USE_VALUE =
|
||||
getClosureSafeProperty<ValueProvider>({provide: String, useValue: getClosureSafeProperty});
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {ChangeDetectorRef} from '../../change_detection/change_detector_ref';
|
||||
import {CompilerFacade, R3DependencyMetadataFacade, R3ResolvedDependencyType, getCompilerFacade} from '../../compiler/compiler_facade';
|
||||
import {CompilerFacade, getCompilerFacade, R3DependencyMetadataFacade, R3ResolvedDependencyType} from '../../compiler/compiler_facade';
|
||||
import {Type} from '../../interface/type';
|
||||
import {ReflectionCapabilities} from '../../reflection/reflection_capabilities';
|
||||
import {Attribute, Host, Inject, Optional, Self, SkipSelf} from '../metadata';
|
||||
@ -27,7 +27,7 @@ export function convertDependencies(deps: any[]): R3DependencyMetadataFacade[] {
|
||||
return deps.map(dep => reflectDependency(compiler, dep));
|
||||
}
|
||||
|
||||
function reflectDependency(compiler: CompilerFacade, dep: any | any[]): R3DependencyMetadataFacade {
|
||||
function reflectDependency(compiler: CompilerFacade, dep: any|any[]): R3DependencyMetadataFacade {
|
||||
const meta: R3DependencyMetadataFacade = {
|
||||
token: null,
|
||||
host: false,
|
||||
|
@ -33,7 +33,7 @@ export interface InjectDecorator {
|
||||
* </code-example>
|
||||
*/
|
||||
(token: any): any;
|
||||
new (token: any): Inject;
|
||||
new(token: any): Inject;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ export interface OptionalDecorator {
|
||||
*
|
||||
*/
|
||||
(): any;
|
||||
new (): Optional;
|
||||
new(): Optional;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +128,7 @@ export interface SelfDecorator {
|
||||
*
|
||||
*/
|
||||
(): any;
|
||||
new (): Self;
|
||||
new(): Self;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,7 +175,7 @@ export interface SkipSelfDecorator {
|
||||
*
|
||||
*/
|
||||
(): any;
|
||||
new (): SkipSelf;
|
||||
new(): SkipSelf;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,7 +215,7 @@ export interface HostDecorator {
|
||||
* </code-example>
|
||||
*/
|
||||
(): any;
|
||||
new (): Host;
|
||||
new(): Host;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -262,7 +262,7 @@ export interface AttributeDecorator {
|
||||
*
|
||||
*/
|
||||
(name: string): any;
|
||||
new (name: string): Attribute;
|
||||
new(name: string): Attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,11 +15,12 @@ import {throwCyclicDependencyError, throwInvalidProviderError, throwMixedMultiPr
|
||||
import {FactoryFn} from '../render3/interfaces/definition';
|
||||
import {deepForEach, newArray} from '../util/array_utils';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {resolveForwardRef} from './forward_ref';
|
||||
import {InjectionToken} from './injection_token';
|
||||
import {Injector} from './injector';
|
||||
import {INJECTOR, NG_TEMP_TOKEN_PATH, NullInjector, THROW_IF_NOT_FOUND, USE_VALUE, catchInjectorError, injectArgs, setCurrentInjector, ɵɵinject} from './injector_compatibility';
|
||||
import {InjectorType, InjectorTypeWithProviders, getInheritedInjectableDef, getInjectableDef, getInjectorDef, ɵɵInjectableDef} from './interface/defs';
|
||||
import {catchInjectorError, injectArgs, INJECTOR, NG_TEMP_TOKEN_PATH, NullInjector, setCurrentInjector, THROW_IF_NOT_FOUND, USE_VALUE, ɵɵinject} from './injector_compatibility';
|
||||
import {getInheritedInjectableDef, getInjectableDef, getInjectorDef, InjectorType, InjectorTypeWithProviders, ɵɵInjectableDef} from './interface/defs';
|
||||
import {InjectFlags} from './interface/injector';
|
||||
import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, StaticProvider, TypeProvider, ValueProvider} from './interface/provider';
|
||||
import {INJECTOR_SCOPE} from './scope';
|
||||
@ -29,8 +30,8 @@ import {INJECTOR_SCOPE} from './scope';
|
||||
/**
|
||||
* Internal type for a single provider in a deep provider array.
|
||||
*/
|
||||
type SingleProvider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider |
|
||||
ExistingProvider | FactoryProvider | StaticClassProvider;
|
||||
type SingleProvider = TypeProvider|ValueProvider|ClassProvider|ConstructorProvider|ExistingProvider|
|
||||
FactoryProvider|StaticClassProvider;
|
||||
|
||||
/**
|
||||
* Marker which indicates that a value has not yet been created from the factory function.
|
||||
@ -76,8 +77,8 @@ interface Record<T> {
|
||||
* @publicApi
|
||||
*/
|
||||
export function createInjector(
|
||||
defType: /* InjectorType<any> */ any, parent: Injector | null = null,
|
||||
additionalProviders: StaticProvider[] | null = null, name?: string): Injector {
|
||||
defType: /* InjectorType<any> */ any, parent: Injector|null = null,
|
||||
additionalProviders: StaticProvider[]|null = null, name?: string): Injector {
|
||||
const injector =
|
||||
createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
|
||||
injector._resolveInjectorDefTypes();
|
||||
@ -90,8 +91,8 @@ export function createInjector(
|
||||
* should be resolved at a later point by calling `_resolveInjectorDefTypes`.
|
||||
*/
|
||||
export function createInjectorWithoutInjectorInstances(
|
||||
defType: /* InjectorType<any> */ any, parent: Injector | null = null,
|
||||
additionalProviders: StaticProvider[] | null = null, name?: string): R3Injector {
|
||||
defType: /* InjectorType<any> */ any, parent: Injector|null = null,
|
||||
additionalProviders: StaticProvider[]|null = null, name?: string): R3Injector {
|
||||
return new R3Injector(defType, additionalProviders, parent || getNullInjector(), name);
|
||||
}
|
||||
|
||||
@ -124,7 +125,9 @@ export class R3Injector {
|
||||
/**
|
||||
* Flag indicating that this injector was previously destroyed.
|
||||
*/
|
||||
get destroyed(): boolean { return this._destroyed; }
|
||||
get destroyed(): boolean {
|
||||
return this._destroyed;
|
||||
}
|
||||
private _destroyed = false;
|
||||
|
||||
constructor(
|
||||
@ -135,9 +138,10 @@ export class R3Injector {
|
||||
// Start off by creating Records for every provider declared in every InjectorType
|
||||
// included transitively in additional providers then do the same for `def`. This order is
|
||||
// important because `def` may include providers that override ones in additionalProviders.
|
||||
additionalProviders && deepForEach(
|
||||
additionalProviders, provider => this.processProvider(
|
||||
provider, def, additionalProviders));
|
||||
additionalProviders &&
|
||||
deepForEach(
|
||||
additionalProviders,
|
||||
provider => this.processProvider(provider, def, additionalProviders));
|
||||
|
||||
deepForEach([def], injectorDef => this.processInjectorType(injectorDef, [], dedupStack));
|
||||
|
||||
@ -235,7 +239,9 @@ export class R3Injector {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
_resolveInjectorDefTypes() { this.injectorDefTypes.forEach(defType => this.get(defType)); }
|
||||
_resolveInjectorDefTypes() {
|
||||
this.injectorDefTypes.forEach(defType => this.get(defType));
|
||||
}
|
||||
|
||||
toString() {
|
||||
const tokens = <string[]>[], records = this.records;
|
||||
@ -285,8 +291,8 @@ export class R3Injector {
|
||||
// Check for circular dependencies.
|
||||
if (ngDevMode && parents.indexOf(defType) !== -1) {
|
||||
const defName = stringify(defType);
|
||||
throw new Error(
|
||||
`Circular dependency in DI detected for type ${defName}. Dependency path: ${parents.map(defType => stringify(defType)).join(' > ')} > ${defName}.`);
|
||||
throw new Error(`Circular dependency in DI detected for type ${defName}. Dependency path: ${
|
||||
parents.map(defType => stringify(defType)).join(' > ')} > ${defName}.`);
|
||||
}
|
||||
|
||||
// Check for multiple imports of the same module
|
||||
@ -335,7 +341,7 @@ export class R3Injector {
|
||||
for (let i = 0; i < importTypesWithProviders.length; i++) {
|
||||
const {ngModule, providers} = importTypesWithProviders[i];
|
||||
deepForEach(
|
||||
providers !,
|
||||
providers!,
|
||||
provider => this.processProvider(provider, ngModule, providers || EMPTY_ARRAY));
|
||||
}
|
||||
}
|
||||
@ -383,11 +389,11 @@ export class R3Injector {
|
||||
}
|
||||
} else {
|
||||
multiRecord = makeRecord(undefined, NOT_YET, true);
|
||||
multiRecord.factory = () => injectArgs(multiRecord !.multi !);
|
||||
multiRecord.factory = () => injectArgs(multiRecord!.multi!);
|
||||
this.records.set(token, multiRecord);
|
||||
}
|
||||
token = provider;
|
||||
multiRecord.multi !.push(provider);
|
||||
multiRecord.multi!.push(provider);
|
||||
} else {
|
||||
const existing = this.records.get(token);
|
||||
if (existing && existing.multi !== undefined) {
|
||||
@ -402,7 +408,7 @@ export class R3Injector {
|
||||
throwCyclicDependencyError(stringify(token));
|
||||
} else if (record.value === NOT_YET) {
|
||||
record.value = CIRCULAR;
|
||||
record.value = record.factory !();
|
||||
record.value = record.factory!();
|
||||
}
|
||||
if (typeof record.value === 'object' && record.value && hasOnDestroy(record.value)) {
|
||||
this.onDestroy.add(record.value);
|
||||
@ -421,7 +427,7 @@ export class R3Injector {
|
||||
}
|
||||
}
|
||||
|
||||
function injectableDefOrInjectorDefFactory(token: Type<any>| InjectionToken<any>): FactoryFn<any> {
|
||||
function injectableDefOrInjectorDefFactory(token: Type<any>|InjectionToken<any>): FactoryFn<any> {
|
||||
// Most tokens will have an injectable def directly on them, which specifies a factory directly.
|
||||
const injectableDef = getInjectableDef(token);
|
||||
const factory = injectableDef !== null ? injectableDef.factory : getFactoryDef(token);
|
||||
@ -519,7 +525,7 @@ export function providerToFactory(
|
||||
}
|
||||
|
||||
function makeRecord<T>(
|
||||
factory: (() => T) | undefined, value: T | {}, multi: boolean = false): Record<T> {
|
||||
factory: (() => T)|undefined, value: T|{}, multi: boolean = false): Record<T> {
|
||||
return {
|
||||
factory: factory,
|
||||
value: value,
|
||||
@ -547,14 +553,14 @@ export function isClassProvider(value: SingleProvider): value is ClassProvider {
|
||||
return !!(value as StaticClassProvider | ClassProvider).useClass;
|
||||
}
|
||||
|
||||
function hasDeps(value: ClassProvider | ConstructorProvider | StaticClassProvider):
|
||||
value is ClassProvider&{deps: any[]} {
|
||||
function hasDeps(value: ClassProvider|ConstructorProvider|
|
||||
StaticClassProvider): value is ClassProvider&{deps: any[]} {
|
||||
return !!(value as any).deps;
|
||||
}
|
||||
|
||||
function hasOnDestroy(value: any): value is OnDestroy {
|
||||
return value !== null && typeof value === 'object' &&
|
||||
typeof(value as OnDestroy).ngOnDestroy === 'function';
|
||||
typeof (value as OnDestroy).ngOnDestroy === 'function';
|
||||
}
|
||||
|
||||
function couldBeInjectableType(value: any): value is Type<any>|InjectionToken<any> {
|
||||
|
@ -143,7 +143,8 @@ export function instantiationError(
|
||||
key: ReflectiveKey): InjectionError {
|
||||
return injectionError(injector, key, function(keys: ReflectiveKey[]) {
|
||||
const first = stringify(keys[0].token);
|
||||
return `${originalException.message}: Error during instantiation of ${first}!${constructResolvingPath(keys)}.`;
|
||||
return `${originalException.message}: Error during instantiation of ${first}!${
|
||||
constructResolvingPath(keys)}.`;
|
||||
}, originalException);
|
||||
}
|
||||
|
||||
@ -193,7 +194,7 @@ export function invalidProviderError(provider: any) {
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
export function noAnnotationError(typeOrFunc: Type<any>| Function, params: any[][]): Error {
|
||||
export function noAnnotationError(typeOrFunc: Type<any>|Function, params: any[][]): Error {
|
||||
const signature: string[] = [];
|
||||
for (let i = 0, ii = params.length; i < ii; i++) {
|
||||
const parameter = params[i];
|
||||
|
@ -308,7 +308,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
|
||||
createChildFromResolved(providers: ResolvedReflectiveProvider[]): ReflectiveInjector {
|
||||
const inj = new ReflectiveInjector_(providers);
|
||||
(inj as{parent: Injector | null}).parent = this;
|
||||
(inj as {parent: Injector | null}).parent = this;
|
||||
return inj;
|
||||
}
|
||||
|
||||
@ -335,7 +335,9 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
return this._instantiateProvider(provider);
|
||||
}
|
||||
|
||||
private _getMaxNumberOfObjects(): number { return this.objs.length; }
|
||||
private _getMaxNumberOfObjects(): number {
|
||||
return this.objs.length;
|
||||
}
|
||||
|
||||
private _instantiateProvider(provider: ResolvedReflectiveProvider): any {
|
||||
if (provider.multiProvider) {
|
||||
@ -451,7 +453,9 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
return `ReflectiveInjector(providers: [${providers}])`;
|
||||
}
|
||||
|
||||
toString(): string { return this.displayName; }
|
||||
toString(): string {
|
||||
return this.displayName;
|
||||
}
|
||||
}
|
||||
|
||||
function _mapProviders(injector: ReflectiveInjector_, fn: Function): any[] {
|
||||
|
@ -50,7 +50,9 @@ export class ReflectiveKey {
|
||||
/**
|
||||
* @returns the number of keys registered in the system.
|
||||
*/
|
||||
static get numberOfKeys(): number { return _globalKeyRegistry.numberOfKeys; }
|
||||
static get numberOfKeys(): number {
|
||||
return _globalKeyRegistry.numberOfKeys;
|
||||
}
|
||||
}
|
||||
|
||||
export class KeyRegistry {
|
||||
@ -60,7 +62,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);
|
||||
@ -68,7 +70,9 @@ export class KeyRegistry {
|
||||
return newKey;
|
||||
}
|
||||
|
||||
get numberOfKeys(): number { return this._allKeys.size; }
|
||||
get numberOfKeys(): number {
|
||||
return this._allKeys.size;
|
||||
}
|
||||
}
|
||||
|
||||
const _globalKeyRegistry = new KeyRegistry();
|
||||
|
@ -18,7 +18,7 @@ import {ReflectiveKey} from './reflective_key';
|
||||
|
||||
|
||||
interface NormalizedProvider extends TypeProvider, ValueProvider, ClassProvider, ExistingProvider,
|
||||
FactoryProvider {}
|
||||
FactoryProvider {}
|
||||
|
||||
/**
|
||||
* `Dependency` is used by the framework to extend DI.
|
||||
@ -184,7 +184,7 @@ function _normalizeProviders(
|
||||
providers: Provider[], res: NormalizedProvider[]): NormalizedProvider[] {
|
||||
providers.forEach(b => {
|
||||
if (b instanceof Type) {
|
||||
res.push({ provide: b, useClass: b } as NormalizedProvider);
|
||||
res.push({provide: b, useClass: b} as NormalizedProvider);
|
||||
|
||||
} else if (b && typeof b == 'object' && (b as any).provide !== undefined) {
|
||||
res.push(b as NormalizedProvider);
|
||||
@ -221,7 +221,7 @@ function _dependenciesFor(typeOrFunc: any): ReflectiveDependency[] {
|
||||
}
|
||||
|
||||
function _extractToken(
|
||||
typeOrFunc: any, metadata: any[] | any, params: any[][]): ReflectiveDependency {
|
||||
typeOrFunc: any, metadata: any[]|any, params: any[][]): ReflectiveDependency {
|
||||
let token: any = null;
|
||||
let optional = false;
|
||||
|
||||
@ -264,6 +264,6 @@ function _extractToken(
|
||||
}
|
||||
|
||||
function _createDependency(
|
||||
token: any, optional: boolean, visibility: Self | SkipSelf | null): ReflectiveDependency {
|
||||
token: any, optional: boolean, visibility: Self|SkipSelf|null): ReflectiveDependency {
|
||||
return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
|
||||
}
|
||||
|
@ -19,8 +19,9 @@ const USE_VALUE =
|
||||
const EMPTY_ARRAY: any[] = [];
|
||||
|
||||
export function convertInjectableProviderToFactory(
|
||||
type: Type<any>, provider?: ValueSansProvider | ExistingSansProvider | StaticClassSansProvider |
|
||||
ConstructorSansProvider | FactorySansProvider | ClassSansProvider): () => any {
|
||||
type: Type<any>,
|
||||
provider?: ValueSansProvider|ExistingSansProvider|StaticClassSansProvider|
|
||||
ConstructorSansProvider|FactorySansProvider|ClassSansProvider): () => any {
|
||||
if (!provider) {
|
||||
const reflectionCapabilities = new ReflectionCapabilities();
|
||||
const deps = reflectionCapabilities.parameters(type);
|
||||
@ -51,6 +52,6 @@ export function convertInjectableProviderToFactory(
|
||||
const reflectionCapabilities = new ReflectionCapabilities();
|
||||
deps = reflectionCapabilities.parameters(type);
|
||||
}
|
||||
return () => new type(...injectArgs(deps !));
|
||||
return () => new type(...injectArgs(deps!));
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,9 @@ export class EventEmitter<T extends any> extends Subject<T> {
|
||||
* Emits an event containing a given value.
|
||||
* @param value The value to emit.
|
||||
*/
|
||||
emit(value?: T) { super.next(value); }
|
||||
emit(value?: T) {
|
||||
super.next(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers handlers for events emitted by this instance.
|
||||
@ -101,29 +103,46 @@ export class EventEmitter<T extends any> extends Subject<T> {
|
||||
if (generatorOrNext && typeof generatorOrNext === 'object') {
|
||||
schedulerFn = this.__isAsync ? (value: any) => {
|
||||
setTimeout(() => generatorOrNext.next(value));
|
||||
} : (value: any) => { generatorOrNext.next(value); };
|
||||
} : (value: any) => {
|
||||
generatorOrNext.next(value);
|
||||
};
|
||||
|
||||
if (generatorOrNext.error) {
|
||||
errorFn = this.__isAsync ? (err) => { setTimeout(() => generatorOrNext.error(err)); } :
|
||||
(err) => { generatorOrNext.error(err); };
|
||||
errorFn = this.__isAsync ? (err) => {
|
||||
setTimeout(() => generatorOrNext.error(err));
|
||||
} : (err) => {
|
||||
generatorOrNext.error(err);
|
||||
};
|
||||
}
|
||||
|
||||
if (generatorOrNext.complete) {
|
||||
completeFn = this.__isAsync ? () => { setTimeout(() => generatorOrNext.complete()); } :
|
||||
() => { generatorOrNext.complete(); };
|
||||
completeFn = this.__isAsync ? () => {
|
||||
setTimeout(() => generatorOrNext.complete());
|
||||
} : () => {
|
||||
generatorOrNext.complete();
|
||||
};
|
||||
}
|
||||
} else {
|
||||
schedulerFn = this.__isAsync ? (value: any) => { setTimeout(() => generatorOrNext(value)); } :
|
||||
(value: any) => { generatorOrNext(value); };
|
||||
schedulerFn = this.__isAsync ? (value: any) => {
|
||||
setTimeout(() => generatorOrNext(value));
|
||||
} : (value: any) => {
|
||||
generatorOrNext(value);
|
||||
};
|
||||
|
||||
if (error) {
|
||||
errorFn =
|
||||
this.__isAsync ? (err) => { setTimeout(() => error(err)); } : (err) => { error(err); };
|
||||
errorFn = this.__isAsync ? (err) => {
|
||||
setTimeout(() => error(err));
|
||||
} : (err) => {
|
||||
error(err);
|
||||
};
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
completeFn =
|
||||
this.__isAsync ? () => { setTimeout(() => complete()); } : () => { complete(); };
|
||||
completeFn = this.__isAsync ? () => {
|
||||
setTimeout(() => complete());
|
||||
} : () => {
|
||||
complete();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,10 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import localeEn from './locale_en';
|
||||
import {global} from '../util/global';
|
||||
|
||||
import localeEn from './locale_en';
|
||||
|
||||
/**
|
||||
* This const is used to store the locale data registered with `registerLocaleData`
|
||||
*/
|
||||
@ -19,7 +20,7 @@ let LOCALE_DATA: {[localeId: string]: any} = {};
|
||||
*
|
||||
* The signature `registerLocaleData(data: any, extraData?: any)` is deprecated since v5.1
|
||||
*/
|
||||
export function registerLocaleData(data: any, localeId?: string | any, extraData?: any): void {
|
||||
export function registerLocaleData(data: any, localeId?: string|any, extraData?: any): void {
|
||||
if (typeof localeId !== 'string') {
|
||||
extraData = localeId;
|
||||
localeId = data[LocaleDataIndex.LocaleId];
|
||||
@ -151,7 +152,11 @@ export const enum ExtraLocaleDataIndex {
|
||||
/**
|
||||
* Index of each value in currency data (used to describe CURRENCIES_EN in currencies.ts)
|
||||
*/
|
||||
export const enum CurrencyIndex {Symbol = 0, SymbolNarrow, NbOfDigits}
|
||||
export const enum CurrencyIndex {
|
||||
Symbol = 0,
|
||||
SymbolNarrow,
|
||||
NbOfDigits
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the canonical form of a locale name - lowercase with `_` replaced with `-`.
|
||||
|
@ -90,12 +90,12 @@ export interface OnInit {
|
||||
*/
|
||||
export interface DoCheck {
|
||||
/**
|
||||
* A callback method that performs change-detection, invoked
|
||||
* after the default change-detector runs.
|
||||
* See `KeyValueDiffers` and `IterableDiffers` for implementing
|
||||
* custom change checking for collections.
|
||||
*
|
||||
*/
|
||||
* A callback method that performs change-detection, invoked
|
||||
* after the default change-detector runs.
|
||||
* See `KeyValueDiffers` and `IterableDiffers` for implementing
|
||||
* custom change checking for collections.
|
||||
*
|
||||
*/
|
||||
ngDoCheck(): void;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,9 @@ export class SimpleChange {
|
||||
/**
|
||||
* Check whether the new value is the first value assigned.
|
||||
*/
|
||||
isFirstChange(): boolean { return this.firstChange; }
|
||||
isFirstChange(): boolean {
|
||||
return this.firstChange;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,4 +34,6 @@ export class SimpleChange {
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface SimpleChanges { [propName: string]: SimpleChange; }
|
||||
export interface SimpleChanges {
|
||||
[propName: string]: SimpleChange;
|
||||
}
|
||||
|
@ -30,11 +30,15 @@ export function isType(v: any): v is Type<any> {
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface AbstractType<T> extends Function { prototype: T; }
|
||||
export interface AbstractType<T> extends Function {
|
||||
prototype: T;
|
||||
}
|
||||
|
||||
export interface Type<T> extends Function { new (...args: any[]): T; }
|
||||
export interface Type<T> extends Function {
|
||||
new(...args: any[]): T;
|
||||
}
|
||||
|
||||
export type Mutable<T extends{[x: string]: any}, K extends string> = {
|
||||
export type Mutable<T extends {[x: string]: any}, K extends string> = {
|
||||
[P in K]: T[P];
|
||||
};
|
||||
|
||||
|
@ -7,12 +7,12 @@
|
||||
*/
|
||||
|
||||
// Public API for compiler
|
||||
export {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, ModuleWithComponentFactories} from './linker/compiler';
|
||||
export {Compiler, COMPILER_OPTIONS, CompilerFactory, CompilerOptions, ModuleWithComponentFactories} from './linker/compiler';
|
||||
export {ComponentFactory, ComponentRef} from './linker/component_factory';
|
||||
export {ComponentFactoryResolver} from './linker/component_factory_resolver';
|
||||
export {ElementRef} from './linker/element_ref';
|
||||
export {NgModuleFactory, NgModuleRef} from './linker/ng_module_factory';
|
||||
export {NgModuleFactoryLoader, getModuleFactory} from './linker/ng_module_factory_loader';
|
||||
export {getModuleFactory, NgModuleFactoryLoader} from './linker/ng_module_factory_loader';
|
||||
export {QueryList} from './linker/query_list';
|
||||
export {SystemJsNgModuleLoader, SystemJsNgModuleLoaderConfig} from './linker/system_js_ng_module_factory_loader';
|
||||
export {TemplateRef} from './linker/template_ref';
|
||||
|
@ -60,7 +60,7 @@ export const Compiler_compileModuleAndAllComponentsSync__POST_R3__: <T>(moduleTy
|
||||
ModuleWithComponentFactories<T> = function<T>(moduleType: Type<T>):
|
||||
ModuleWithComponentFactories<T> {
|
||||
const ngModuleFactory = Compiler_compileModuleSync__POST_R3__(moduleType);
|
||||
const moduleDef = getNgModuleDef(moduleType) !;
|
||||
const moduleDef = getNgModuleDef(moduleType)!;
|
||||
const componentFactories =
|
||||
maybeUnwrapFn(moduleDef.declarations)
|
||||
.reduce((factories: ComponentFactory<any>[], declaration: Type<any>) => {
|
||||
@ -133,7 +133,9 @@ export class Compiler {
|
||||
/**
|
||||
* Returns the id for a given NgModule, if one is defined and known to the compiler.
|
||||
*/
|
||||
getModuleId(moduleType: Type<any>): string|undefined { return undefined; }
|
||||
getModuleId(moduleType: Type<any>): string|undefined {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,8 +14,8 @@ import {ComponentFactory, ComponentRef} from './component_factory';
|
||||
import {NgModuleRef} from './ng_module_factory';
|
||||
|
||||
export function noComponentFactoryError(component: Function) {
|
||||
const error = Error(
|
||||
`No component factory found for ${stringify(component)}. Did you add it to @NgModule.entryComponents?`);
|
||||
const error = Error(`No component factory found for ${
|
||||
stringify(component)}. Did you add it to @NgModule.entryComponents?`);
|
||||
(error as any)[ERROR_COMPONENT] = component;
|
||||
return error;
|
||||
}
|
||||
@ -28,7 +28,7 @@ export function getComponent(error: Error): Type<any> {
|
||||
|
||||
|
||||
class _NullComponentFactoryResolver implements ComponentFactoryResolver {
|
||||
resolveComponentFactory<T>(component: {new (...args: any[]): T}): ComponentFactory<T> {
|
||||
resolveComponentFactory<T>(component: {new(...args: any[]): T}): ComponentFactory<T> {
|
||||
throw noComponentFactoryError(component);
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ export class CodegenComponentFactoryResolver implements ComponentFactoryResolver
|
||||
}
|
||||
}
|
||||
|
||||
resolveComponentFactory<T>(component: {new (...args: any[]): T}): ComponentFactory<T> {
|
||||
resolveComponentFactory<T>(component: {new(...args: any[]): T}): ComponentFactory<T> {
|
||||
let factory = this._factories.get(component);
|
||||
if (!factory && this._parent) {
|
||||
factory = this._parent.resolveComponentFactory(component);
|
||||
|
@ -48,7 +48,9 @@ export class ElementRef<T extends any = any> {
|
||||
*/
|
||||
public nativeElement: T;
|
||||
|
||||
constructor(nativeElement: T) { this.nativeElement = nativeElement; }
|
||||
constructor(nativeElement: T) {
|
||||
this.nativeElement = nativeElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -43,6 +43,8 @@ export function getModuleFactory__POST_R3__(id: string): NgModuleFactory<any> {
|
||||
*/
|
||||
export const getModuleFactory: (id: string) => NgModuleFactory<any> = getModuleFactory__PRE_R3__;
|
||||
|
||||
function noModuleError(id: string, ): Error {
|
||||
function noModuleError(
|
||||
id: string,
|
||||
): Error {
|
||||
return new Error(`No module with ID ${id} loaded`);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ export function registerModuleFactory(id: string, factory: NgModuleFactory<any>)
|
||||
modules.set(id, factory);
|
||||
}
|
||||
|
||||
function assertSameOrNotExisting(id: string, type: Type<any>| null, incoming: Type<any>): void {
|
||||
function assertSameOrNotExisting(id: string, type: Type<any>|null, incoming: Type<any>): void {
|
||||
if (type && type !== incoming) {
|
||||
throw new Error(
|
||||
`Duplicate module registered for ${id} - ${stringify(type)} vs ${stringify(type.name)}`);
|
||||
|
@ -13,7 +13,7 @@ import {flatten} from '../util/array_utils';
|
||||
import {getSymbolIterator} from '../util/symbol';
|
||||
|
||||
function symbolIterator<T>(this: QueryList<T>): Iterator<T> {
|
||||
return ((this as any as{_results: Array<T>})._results as any)[getSymbolIterator()]();
|
||||
return ((this as any as {_results: Array<T>})._results as any)[getSymbolIterator()]();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,9 +49,9 @@ export class QueryList<T> implements Iterable<T> {
|
||||
|
||||
readonly length: number = 0;
|
||||
// TODO(issue/24571): remove '!'.
|
||||
readonly first !: T;
|
||||
readonly first!: T;
|
||||
// TODO(issue/24571): remove '!'.
|
||||
readonly last !: T;
|
||||
readonly last!: T;
|
||||
|
||||
constructor() {
|
||||
// This function should be declared on the prototype, but doing so there will cause the class
|
||||
@ -67,7 +67,9 @@ export class QueryList<T> implements Iterable<T> {
|
||||
* See
|
||||
* [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
|
||||
*/
|
||||
map<U>(fn: (item: T, index: number, array: T[]) => U): U[] { return this._results.map(fn); }
|
||||
map<U>(fn: (item: T, index: number, array: T[]) => U): U[] {
|
||||
return this._results.map(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* See
|
||||
@ -97,7 +99,9 @@ export class QueryList<T> implements Iterable<T> {
|
||||
* See
|
||||
* [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
|
||||
*/
|
||||
forEach(fn: (item: T, index: number, array: T[]) => void): void { this._results.forEach(fn); }
|
||||
forEach(fn: (item: T, index: number, array: T[]) => void): void {
|
||||
this._results.forEach(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* See
|
||||
@ -110,9 +114,13 @@ export class QueryList<T> implements Iterable<T> {
|
||||
/**
|
||||
* Returns a copy of the internal results list as an Array.
|
||||
*/
|
||||
toArray(): T[] { return this._results.slice(); }
|
||||
toArray(): T[] {
|
||||
return this._results.slice();
|
||||
}
|
||||
|
||||
toString(): string { return this._results.toString(); }
|
||||
toString(): string {
|
||||
return this._results.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the stored data of the query list, and resets the `dirty` flag to `false`, so that
|
||||
@ -123,19 +131,23 @@ export class QueryList<T> implements Iterable<T> {
|
||||
*/
|
||||
reset(resultsTree: Array<T|any[]>): void {
|
||||
this._results = flatten(resultsTree);
|
||||
(this as{dirty: boolean}).dirty = false;
|
||||
(this as{length: number}).length = this._results.length;
|
||||
(this as{last: T}).last = this._results[this.length - 1];
|
||||
(this as{first: T}).first = this._results[0];
|
||||
(this as {dirty: boolean}).dirty = false;
|
||||
(this as {length: number}).length = this._results.length;
|
||||
(this as {last: T}).last = this._results[this.length - 1];
|
||||
(this as {first: T}).first = this._results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a change event by emitting on the `changes` {@link EventEmitter}.
|
||||
*/
|
||||
notifyOnChanges(): void { (this.changes as EventEmitter<any>).emit(this); }
|
||||
notifyOnChanges(): void {
|
||||
(this.changes as EventEmitter<any>).emit(this);
|
||||
}
|
||||
|
||||
/** internal */
|
||||
setDirty() { (this as{dirty: boolean}).dirty = true; }
|
||||
setDirty() {
|
||||
(this as {dirty: boolean}).dirty = true;
|
||||
}
|
||||
|
||||
/** internal */
|
||||
destroy(): void {
|
||||
@ -148,5 +160,5 @@ export class QueryList<T> implements Iterable<T> {
|
||||
// there) and this declaration is left here to ensure that TypeScript considers QueryList to
|
||||
// implement the Iterable interface. This is required for template type-checking of NgFor loops
|
||||
// over QueryLists to work correctly, since QueryList must be assignable to NgIterable.
|
||||
[Symbol.iterator] !: () => Iterator<T>;
|
||||
[Symbol.iterator]!: () => Iterator<T>;
|
||||
}
|
||||
|
@ -32,13 +32,13 @@ export abstract class SystemJsNgModuleLoaderConfig {
|
||||
* Prefix to add when computing the name of the factory module for a given module name.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
factoryPathPrefix !: string;
|
||||
factoryPathPrefix!: string;
|
||||
|
||||
/**
|
||||
* Suffix to add when computing the name of the factory module for a given module name.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
factoryPathSuffix !: string;
|
||||
factoryPathSuffix!: string;
|
||||
}
|
||||
|
||||
const DEFAULT_CONFIG: SystemJsNgModuleLoaderConfig = {
|
||||
|
@ -75,7 +75,7 @@ export interface AttributeDecorator {
|
||||
* @publicApi
|
||||
*/
|
||||
(name: string): any;
|
||||
new (name: string): Attribute;
|
||||
new(name: string): Attribute;
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +158,7 @@ export interface ContentChildrenDecorator {
|
||||
* @Annotation
|
||||
*/
|
||||
(selector: Type<any>|Function|string, opts?: {descendants?: boolean, read?: any}): any;
|
||||
new (selector: Type<any>|Function|string, opts?: {descendants?: boolean, read?: any}): Query;
|
||||
new(selector: Type<any>|Function|string, opts?: {descendants?: boolean, read?: any}): Query;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,7 +219,7 @@ export interface ContentChildDecorator {
|
||||
* @Annotation
|
||||
*/
|
||||
(selector: Type<any>|Function|string, opts?: {read?: any, static?: boolean}): any;
|
||||
new (selector: Type<any>|Function|string, opts?: {read?: any, static?: boolean}): ContentChild;
|
||||
new(selector: Type<any>|Function|string, opts?: {read?: any, static?: boolean}): ContentChild;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -238,8 +238,9 @@ export type ContentChild = Query;
|
||||
* @publicApi
|
||||
*/
|
||||
export const ContentChild: ContentChildDecorator = makePropDecorator(
|
||||
'ContentChild', (selector?: any, data: any = {}) =>
|
||||
({selector, first: true, isViewQuery: false, descendants: true, ...data}),
|
||||
'ContentChild',
|
||||
(selector?: any, data: any = {}) =>
|
||||
({selector, first: true, isViewQuery: false, descendants: true, ...data}),
|
||||
Query);
|
||||
|
||||
/**
|
||||
@ -275,7 +276,7 @@ export interface ViewChildrenDecorator {
|
||||
* @Annotation
|
||||
*/
|
||||
(selector: Type<any>|Function|string, opts?: {read?: any}): any;
|
||||
new (selector: Type<any>|Function|string, opts?: {read?: any}): ViewChildren;
|
||||
new(selector: Type<any>|Function|string, opts?: {read?: any}): ViewChildren;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,8 +293,9 @@ export type ViewChildren = Query;
|
||||
* @publicApi
|
||||
*/
|
||||
export const ViewChildren: ViewChildrenDecorator = makePropDecorator(
|
||||
'ViewChildren', (selector?: any, data: any = {}) =>
|
||||
({selector, first: false, isViewQuery: true, descendants: true, ...data}),
|
||||
'ViewChildren',
|
||||
(selector?: any, data: any = {}) =>
|
||||
({selector, first: false, isViewQuery: true, descendants: true, ...data}),
|
||||
Query);
|
||||
|
||||
/**
|
||||
@ -342,7 +344,7 @@ export interface ViewChildDecorator {
|
||||
* @Annotation
|
||||
*/
|
||||
(selector: Type<any>|Function|string, opts?: {read?: any, static?: boolean}): any;
|
||||
new (selector: Type<any>|Function|string, opts?: {read?: any, static?: boolean}): ViewChild;
|
||||
new(selector: Type<any>|Function|string, opts?: {read?: any, static?: boolean}): ViewChild;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -359,6 +361,7 @@ export type ViewChild = Query;
|
||||
* @publicApi
|
||||
*/
|
||||
export const ViewChild: ViewChildDecorator = makePropDecorator(
|
||||
'ViewChild', (selector: any, data: any) =>
|
||||
({selector, first: true, isViewQuery: true, descendants: true, ...data}),
|
||||
'ViewChild',
|
||||
(selector: any, data: any) =>
|
||||
({selector, first: true, isViewQuery: true, descendants: true, ...data}),
|
||||
Query);
|
||||
|
@ -11,7 +11,7 @@ import {Provider} from '../di';
|
||||
import {Type} from '../interface/type';
|
||||
import {compileComponent as render3CompileComponent, compileDirective as render3CompileDirective} from '../render3/jit/directive';
|
||||
import {compilePipe as render3CompilePipe} from '../render3/jit/pipe';
|
||||
import {TypeDecorator, makeDecorator, makePropDecorator} from '../util/decorators';
|
||||
import {makeDecorator, makePropDecorator, TypeDecorator} from '../util/decorators';
|
||||
import {noop} from '../util/noop';
|
||||
|
||||
import {ViewEncapsulation} from './view';
|
||||
@ -73,7 +73,7 @@ export interface DirectiveDecorator {
|
||||
/**
|
||||
* See the `Directive` decorator.
|
||||
*/
|
||||
new (obj?: Directive): Directive;
|
||||
new(obj?: Directive): Directive;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -445,7 +445,7 @@ export interface ComponentDecorator {
|
||||
/**
|
||||
* See the `Component` decorator.
|
||||
*/
|
||||
new (obj: Component): Component;
|
||||
new(obj: Component): Component;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -598,7 +598,7 @@ export interface PipeDecorator {
|
||||
/**
|
||||
* See the `Pipe` decorator.
|
||||
*/
|
||||
new (obj: Pipe): Pipe;
|
||||
new(obj: Pipe): Pipe;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -641,52 +641,52 @@ export const Pipe: PipeDecorator = makeDecorator(
|
||||
*/
|
||||
export interface InputDecorator {
|
||||
/**
|
||||
* Decorator that marks a class field as an input property and supplies configuration metadata.
|
||||
* The input property is bound to a DOM property in the template. During change detection,
|
||||
* Angular automatically updates the data property with the DOM property's value.
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* You can supply an optional name to use in templates when the
|
||||
* component is instantiated, that maps to the
|
||||
* name of the bound property. By default, the original
|
||||
* name of the bound property is used for input binding.
|
||||
*
|
||||
* The following example creates a component with two input properties,
|
||||
* one of which is given a special binding name.
|
||||
*
|
||||
* ```typescript
|
||||
* @Component({
|
||||
* selector: 'bank-account',
|
||||
* template: `
|
||||
* Bank Name: {{bankName}}
|
||||
* Account Id: {{id}}
|
||||
* `
|
||||
* })
|
||||
* class BankAccount {
|
||||
* // This property is bound using its original name.
|
||||
* @Input() bankName: string;
|
||||
* // this property value is bound to a different property name
|
||||
* // when this component is instantiated in a template.
|
||||
* @Input('account-id') id: string;
|
||||
*
|
||||
* // this property is not bound, and is not automatically updated by Angular
|
||||
* normalizedBankName: string;
|
||||
* }
|
||||
*
|
||||
* @Component({
|
||||
* selector: 'app',
|
||||
* template: `
|
||||
* <bank-account bankName="RBC" account-id="4747"></bank-account>
|
||||
* `
|
||||
* })
|
||||
* class App {}
|
||||
* ```
|
||||
*
|
||||
* @see [Input and Output properties](guide/template-syntax#input-and-output-properties)
|
||||
*/
|
||||
* Decorator that marks a class field as an input property and supplies configuration metadata.
|
||||
* The input property is bound to a DOM property in the template. During change detection,
|
||||
* Angular automatically updates the data property with the DOM property's value.
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* You can supply an optional name to use in templates when the
|
||||
* component is instantiated, that maps to the
|
||||
* name of the bound property. By default, the original
|
||||
* name of the bound property is used for input binding.
|
||||
*
|
||||
* The following example creates a component with two input properties,
|
||||
* one of which is given a special binding name.
|
||||
*
|
||||
* ```typescript
|
||||
* @Component({
|
||||
* selector: 'bank-account',
|
||||
* template: `
|
||||
* Bank Name: {{bankName}}
|
||||
* Account Id: {{id}}
|
||||
* `
|
||||
* })
|
||||
* class BankAccount {
|
||||
* // This property is bound using its original name.
|
||||
* @Input() bankName: string;
|
||||
* // this property value is bound to a different property name
|
||||
* // when this component is instantiated in a template.
|
||||
* @Input('account-id') id: string;
|
||||
*
|
||||
* // this property is not bound, and is not automatically updated by Angular
|
||||
* normalizedBankName: string;
|
||||
* }
|
||||
*
|
||||
* @Component({
|
||||
* selector: 'app',
|
||||
* template: `
|
||||
* <bank-account bankName="RBC" account-id="4747"></bank-account>
|
||||
* `
|
||||
* })
|
||||
* class App {}
|
||||
* ```
|
||||
*
|
||||
* @see [Input and Output properties](guide/template-syntax#input-and-output-properties)
|
||||
*/
|
||||
(bindingPropertyName?: string): any;
|
||||
new (bindingPropertyName?: string): any;
|
||||
new(bindingPropertyName?: string): any;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -715,23 +715,23 @@ export const Input: InputDecorator =
|
||||
*/
|
||||
export interface OutputDecorator {
|
||||
/**
|
||||
* Decorator that marks a class field as an output property and supplies configuration metadata.
|
||||
* The DOM property bound to the output property is automatically updated during change detection.
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* You can supply an optional name to use in templates when the
|
||||
* component is instantiated, that maps to the
|
||||
* name of the bound property. By default, the original
|
||||
* name of the bound property is used for output binding.
|
||||
*
|
||||
* See `Input` decorator for an example of providing a binding name.
|
||||
*
|
||||
* @see [Input and Output properties](guide/template-syntax#input-and-output-properties)
|
||||
*
|
||||
*/
|
||||
* Decorator that marks a class field as an output property and supplies configuration metadata.
|
||||
* The DOM property bound to the output property is automatically updated during change detection.
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* You can supply an optional name to use in templates when the
|
||||
* component is instantiated, that maps to the
|
||||
* name of the bound property. By default, the original
|
||||
* name of the bound property is used for output binding.
|
||||
*
|
||||
* See `Input` decorator for an example of providing a binding name.
|
||||
*
|
||||
* @see [Input and Output properties](guide/template-syntax#input-and-output-properties)
|
||||
*
|
||||
*/
|
||||
(bindingPropertyName?: string): any;
|
||||
new (bindingPropertyName?: string): any;
|
||||
new(bindingPropertyName?: string): any;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -741,8 +741,8 @@ export interface OutputDecorator {
|
||||
*/
|
||||
export interface Output {
|
||||
/**
|
||||
* The name of the DOM property to which the output property is bound.
|
||||
*/
|
||||
* The name of the DOM property to which the output property is bound.
|
||||
*/
|
||||
bindingPropertyName?: string;
|
||||
}
|
||||
|
||||
@ -791,7 +791,7 @@ export interface HostBindingDecorator {
|
||||
*
|
||||
*/
|
||||
(hostPropertyName?: string): any;
|
||||
new (hostPropertyName?: string): any;
|
||||
new(hostPropertyName?: string): any;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -825,7 +825,7 @@ export interface HostListenerDecorator {
|
||||
* and provides a handler method to run when that event occurs.
|
||||
*/
|
||||
(eventName: string, args?: string[]): any;
|
||||
new (eventName: string, args?: string[]): any;
|
||||
new(eventName: string, args?: string[]): any;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ import {convertInjectableProviderToFactory} from '../di/util';
|
||||
import {Type} from '../interface/type';
|
||||
import {SchemaMetadata} from '../metadata/schema';
|
||||
import {compileNgModule as render3CompileNgModule} from '../render3/jit/module';
|
||||
import {TypeDecorator, makeDecorator} from '../util/decorators';
|
||||
import {makeDecorator, TypeDecorator} from '../util/decorators';
|
||||
|
||||
|
||||
/**
|
||||
@ -107,7 +107,7 @@ export interface NgModuleDecorator {
|
||||
* Decorator that marks a class as an NgModule and supplies configuration metadata.
|
||||
*/
|
||||
(obj?: NgModule): TypeDecorator;
|
||||
new (obj?: NgModule): NgModule;
|
||||
new(obj?: NgModule): NgModule;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -345,7 +345,9 @@ export const NgModule: NgModuleDecorator = makeDecorator(
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface DoBootstrap { ngDoBootstrap(appRef: ApplicationRef): void; }
|
||||
export interface DoBootstrap {
|
||||
ngDoBootstrap(appRef: ApplicationRef): void;
|
||||
}
|
||||
|
||||
function preR3NgModuleCompile(moduleType: Type<any>, metadata?: NgModule): void {
|
||||
let imports = (metadata && metadata.imports) || [];
|
||||
|
@ -122,7 +122,7 @@ export function isComponentResourceResolutionQueueEmpty() {
|
||||
return componentResourceResolutionQueue.size === 0;
|
||||
}
|
||||
|
||||
function unwrapResponse(response: string | {text(): Promise<string>}): string|Promise<string> {
|
||||
function unwrapResponse(response: string|{text(): Promise<string>}): string|Promise<string> {
|
||||
return typeof response == 'string' ? response : response.text();
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,9 @@
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface SchemaMetadata { name: string; }
|
||||
export interface SchemaMetadata {
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a schema that allows an NgModule to contain the following:
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {PlatformRef, createPlatformFactory} from './application_ref';
|
||||
import {createPlatformFactory, PlatformRef} from './application_ref';
|
||||
import {PLATFORM_ID} from './application_tokens';
|
||||
import {Console} from './console';
|
||||
import {Injector, StaticProvider} from './di';
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
export {ɵɵinject} from './di/injector_compatibility';
|
||||
export {ɵɵInjectableDef, ɵɵInjectorDef, ɵɵdefineInjectable, ɵɵdefineInjector} from './di/interface/defs';
|
||||
export {ɵɵdefineInjectable, ɵɵdefineInjector, ɵɵInjectableDef, ɵɵInjectorDef} from './di/interface/defs';
|
||||
export {NgModuleDef, ɵɵNgModuleDefWithMeta} from './metadata/ng_module';
|
||||
export {ɵɵdefineNgModule} from './render3/definition';
|
||||
export {ɵɵFactoryDef} from './render3/interfaces/definition';
|
||||
|
@ -6,11 +6,12 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type, isType} from '../interface/type';
|
||||
import {isType, Type} from '../interface/type';
|
||||
import {newArray} from '../util/array_utils';
|
||||
import {ANNOTATIONS, PARAMETERS, PROP_METADATA} from '../util/decorators';
|
||||
import {global} from '../util/global';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {PlatformReflectionCapabilities} from './platform_reflection_capabilities';
|
||||
import {GetterFn, MethodFn, SetterFn} from './types';
|
||||
|
||||
@ -42,11 +43,17 @@ export function isDelegateCtor(typeStr: string): boolean {
|
||||
export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||
private _reflect: any;
|
||||
|
||||
constructor(reflect?: any) { this._reflect = reflect || global['Reflect']; }
|
||||
constructor(reflect?: any) {
|
||||
this._reflect = reflect || global['Reflect'];
|
||||
}
|
||||
|
||||
isReflectionEnabled(): boolean { return true; }
|
||||
isReflectionEnabled(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
factory<T>(t: Type<T>): (args: any[]) => T { return (...args: any[]) => new t(...args); }
|
||||
factory<T>(t: Type<T>): (args: any[]) => T {
|
||||
return (...args: any[]) => new t(...args);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
_zipTypesAndAnnotations(paramTypes: any[], paramAnnotations: any[]): any[][] {
|
||||
@ -235,9 +242,13 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||
return type instanceof Type && lcProperty in type.prototype;
|
||||
}
|
||||
|
||||
guards(type: any): {[key: string]: any} { return {}; }
|
||||
guards(type: any): {[key: string]: any} {
|
||||
return {};
|
||||
}
|
||||
|
||||
getter(name: string): GetterFn { return <GetterFn>new Function('o', 'return o.' + name + ';'); }
|
||||
getter(name: string): GetterFn {
|
||||
return <GetterFn>new Function('o', 'return o.' + name + ';');
|
||||
}
|
||||
|
||||
setter(name: string): SetterFn {
|
||||
return <SetterFn>new Function('o', 'v', 'return o.' + name + ' = v;');
|
||||
@ -259,12 +270,16 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||
return `./${stringify(type)}`;
|
||||
}
|
||||
|
||||
resourceUri(type: any): string { return `./${stringify(type)}`; }
|
||||
resourceUri(type: any): string {
|
||||
return `./${stringify(type)}`;
|
||||
}
|
||||
|
||||
resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any {
|
||||
return runtime;
|
||||
}
|
||||
resolveEnum(enumIdentifier: any, name: string): any { return enumIdentifier[name]; }
|
||||
resolveEnum(enumIdentifier: any, name: string): any {
|
||||
return enumIdentifier[name];
|
||||
}
|
||||
}
|
||||
|
||||
function convertTsickleDecoratorIntoMetadata(decoratorInvocations: any[]): any[] {
|
||||
|
@ -20,9 +20,13 @@ export {GetterFn, MethodFn, SetterFn};
|
||||
export class Reflector {
|
||||
constructor(public reflectionCapabilities: PlatformReflectionCapabilities) {}
|
||||
|
||||
updateCapabilities(caps: PlatformReflectionCapabilities) { this.reflectionCapabilities = caps; }
|
||||
updateCapabilities(caps: PlatformReflectionCapabilities) {
|
||||
this.reflectionCapabilities = caps;
|
||||
}
|
||||
|
||||
factory(type: Type<any>): Function { return this.reflectionCapabilities.factory(type); }
|
||||
factory(type: Type<any>): Function {
|
||||
return this.reflectionCapabilities.factory(type);
|
||||
}
|
||||
|
||||
parameters(typeOrFunc: Type<any>): any[][] {
|
||||
return this.reflectionCapabilities.parameters(typeOrFunc);
|
||||
@ -40,15 +44,25 @@ export class Reflector {
|
||||
return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
|
||||
}
|
||||
|
||||
getter(name: string): GetterFn { return this.reflectionCapabilities.getter(name); }
|
||||
getter(name: string): GetterFn {
|
||||
return this.reflectionCapabilities.getter(name);
|
||||
}
|
||||
|
||||
setter(name: string): SetterFn { return this.reflectionCapabilities.setter(name); }
|
||||
setter(name: string): SetterFn {
|
||||
return this.reflectionCapabilities.setter(name);
|
||||
}
|
||||
|
||||
method(name: string): MethodFn { return this.reflectionCapabilities.method(name); }
|
||||
method(name: string): MethodFn {
|
||||
return this.reflectionCapabilities.method(name);
|
||||
}
|
||||
|
||||
importUri(type: any): string { return this.reflectionCapabilities.importUri(type); }
|
||||
importUri(type: any): string {
|
||||
return this.reflectionCapabilities.importUri(type);
|
||||
}
|
||||
|
||||
resourceUri(type: any): string { return this.reflectionCapabilities.resourceUri(type); }
|
||||
resourceUri(type: any): string {
|
||||
return this.reflectionCapabilities.resourceUri(type);
|
||||
}
|
||||
|
||||
resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any {
|
||||
return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
|
||||
|
@ -145,7 +145,7 @@ export abstract class Renderer2 {
|
||||
* This is used as a performance optimization for production mode.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
destroyNode !: ((node: any) => void) | null;
|
||||
destroyNode!: ((node: any) => void)|null;
|
||||
/**
|
||||
* Appends a child to a given parent node in the host element DOM.
|
||||
* @param parent The parent node.
|
||||
|
@ -20,9 +20,10 @@ import {LView, TVIEW, TView} from './interfaces/view';
|
||||
|
||||
|
||||
export function assertTNodeForLView(tNode: TNode, lView: LView) {
|
||||
tNode.hasOwnProperty('tView_') && assertEqual(
|
||||
(tNode as any as{tView_: TView}).tView_, lView[TVIEW],
|
||||
'This TNode does not belong to this LView.');
|
||||
tNode.hasOwnProperty('tView_') &&
|
||||
assertEqual(
|
||||
(tNode as any as {tView_: TView}).tView_, lView[TVIEW],
|
||||
'This TNode does not belong to this LView.');
|
||||
}
|
||||
|
||||
export function assertComponentType(
|
||||
@ -45,9 +46,9 @@ export function assertPreviousIsParent(isParent: boolean) {
|
||||
assertEqual(isParent, true, 'previousOrParentTNode should be a parent');
|
||||
}
|
||||
|
||||
export function assertHasParent(tNode: TNode | null) {
|
||||
export function assertHasParent(tNode: TNode|null) {
|
||||
assertDefined(tNode, 'previousOrParentTNode should exist!');
|
||||
assertDefined(tNode !.parent, 'previousOrParentTNode should have a parent');
|
||||
assertDefined(tNode!.parent, 'previousOrParentTNode should have a parent');
|
||||
}
|
||||
|
||||
export function assertDataNext(lView: LView, index: number, arr?: any[]) {
|
||||
|
@ -12,15 +12,16 @@ import {Type} from '../core';
|
||||
import {Injector} from '../di/injector';
|
||||
import {Sanitizer} from '../sanitization/sanitizer';
|
||||
import {assertDataInRange} from '../util/assert';
|
||||
|
||||
import {assertComponentType} from './assert';
|
||||
import {getComponentDef} from './definition';
|
||||
import {diPublicInInjector, getOrCreateNodeInjectorForNode} from './di';
|
||||
import {registerPostOrderHooks} from './hooks';
|
||||
import {CLEAN_PROMISE, addHostBindingsToExpandoInstructions, addToViewTree, createLView, createTView, getOrCreateTComponentView, getOrCreateTNode, growHostVarsSpace, initTNodeFlags, instantiateRootComponent, invokeHostBindingsInCreationMode, locateHostElement, markAsComponentHost, refreshView, renderView} from './instructions/shared';
|
||||
import {addHostBindingsToExpandoInstructions, addToViewTree, CLEAN_PROMISE, createLView, createTView, getOrCreateTComponentView, getOrCreateTNode, growHostVarsSpace, initTNodeFlags, instantiateRootComponent, invokeHostBindingsInCreationMode, locateHostElement, markAsComponentHost, refreshView, renderView} from './instructions/shared';
|
||||
import {ComponentDef, ComponentType, RenderFlags} from './interfaces/definition';
|
||||
import {TElementNode, TNode, TNodeType} from './interfaces/node';
|
||||
import {PlayerHandler} from './interfaces/player';
|
||||
import {RElement, Renderer3, RendererFactory3, domRendererFactory3} from './interfaces/renderer';
|
||||
import {domRendererFactory3, RElement, Renderer3, RendererFactory3} from './interfaces/renderer';
|
||||
import {CONTEXT, HEADER_OFFSET, LView, LViewFlags, RootContext, RootContextFlags, TVIEW, TViewType} from './interfaces/view';
|
||||
import {writeDirectClass, writeDirectStyle} from './node_manipulation';
|
||||
import {enterView, getPreviousOrParentTNode, leaveView, setSelectedIndex} from './state';
|
||||
@ -107,7 +108,7 @@ export const NULL_INJECTOR: Injector = {
|
||||
*/
|
||||
export function renderComponent<T>(
|
||||
componentType: ComponentType<T>|
|
||||
Type<T>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */
|
||||
Type<T>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */
|
||||
,
|
||||
opts: CreateComponentOptions = {}): T {
|
||||
ngDevMode && publishDefaultGlobalUtils();
|
||||
@ -115,11 +116,11 @@ export function renderComponent<T>(
|
||||
|
||||
const rendererFactory = opts.rendererFactory || domRendererFactory3;
|
||||
const sanitizer = opts.sanitizer || null;
|
||||
const componentDef = getComponentDef<T>(componentType) !;
|
||||
if (componentDef.type != componentType) (componentDef as{type: Type<any>}).type = componentType;
|
||||
const componentDef = getComponentDef<T>(componentType)!;
|
||||
if (componentDef.type != componentType) (componentDef as {type: Type<any>}).type = componentType;
|
||||
|
||||
// The first index of the first selector is the tag name.
|
||||
const componentTag = componentDef.selectors ![0] ![0] as string;
|
||||
const componentTag = componentDef.selectors![0]![0] as string;
|
||||
const hostRenderer = rendererFactory.createRenderer(null, null);
|
||||
const hostRNode =
|
||||
locateHostElement(hostRenderer, opts.host || componentTag, componentDef.encapsulation);
|
||||
@ -168,9 +169,8 @@ export function renderComponent<T>(
|
||||
* @returns Component view created
|
||||
*/
|
||||
export function createRootComponentView(
|
||||
rNode: RElement | null, def: ComponentDef<any>, rootView: LView,
|
||||
rendererFactory: RendererFactory3, hostRenderer: Renderer3,
|
||||
sanitizer?: Sanitizer | null): LView {
|
||||
rNode: RElement|null, def: ComponentDef<any>, rootView: LView,
|
||||
rendererFactory: RendererFactory3, hostRenderer: Renderer3, sanitizer?: Sanitizer|null): LView {
|
||||
const tView = rootView[TVIEW];
|
||||
ngDevMode && assertDataInRange(rootView, 0 + HEADER_OFFSET);
|
||||
rootView[0 + HEADER_OFFSET] = rNode;
|
||||
@ -213,7 +213,7 @@ export function createRootComponentView(
|
||||
*/
|
||||
export function createRootComponent<T>(
|
||||
componentView: LView, componentDef: ComponentDef<T>, rootLView: LView, rootContext: RootContext,
|
||||
hostFeatures: HostFeature[] | null): any {
|
||||
hostFeatures: HostFeature[]|null): any {
|
||||
const tView = rootLView[TVIEW];
|
||||
// Create directive instance with factory() and store at next index in viewData
|
||||
const component = instantiateRootComponent(tView, rootLView, componentDef);
|
||||
@ -270,13 +270,13 @@ export function createRootContext(
|
||||
* ```
|
||||
*/
|
||||
export function LifecycleHooksFeature(component: any, def: ComponentDef<any>): void {
|
||||
const rootTView = readPatchedLView(component) ![TVIEW];
|
||||
const rootTView = readPatchedLView(component)![TVIEW];
|
||||
const dirIndex = rootTView.data.length - 1;
|
||||
|
||||
// TODO(misko): replace `as TNode` with createTNode call. (needs refactoring to lose dep on
|
||||
// LNode).
|
||||
registerPostOrderHooks(
|
||||
rootTView, { directiveStart: dirIndex, directiveEnd: dirIndex + 1 } as TNode);
|
||||
rootTView, {directiveStart: dirIndex, directiveEnd: dirIndex + 1} as TNode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,13 +21,13 @@ import {VERSION} from '../version';
|
||||
import {NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR} from '../view/provider';
|
||||
|
||||
import {assertComponentType} from './assert';
|
||||
import {LifecycleHooksFeature, createRootComponent, createRootComponentView, createRootContext} from './component';
|
||||
import {createRootComponent, createRootComponentView, createRootContext, LifecycleHooksFeature} from './component';
|
||||
import {getComponentDef} from './definition';
|
||||
import {NodeInjector} from './di';
|
||||
import {assignTViewNodeToLView, createLView, createTView, elementCreate, locateHostElement, renderView} from './instructions/shared';
|
||||
import {ComponentDef} from './interfaces/definition';
|
||||
import {TContainerNode, TElementContainerNode, TElementNode} from './interfaces/node';
|
||||
import {RNode, RendererFactory3, domRendererFactory3} from './interfaces/renderer';
|
||||
import {domRendererFactory3, RendererFactory3, RNode} from './interfaces/renderer';
|
||||
import {LView, LViewFlags, TVIEW, TViewType} from './interfaces/view';
|
||||
import {MATH_ML_NAMESPACE, SVG_NAMESPACE} from './namespaces';
|
||||
import {writeDirectClass} from './node_manipulation';
|
||||
@ -43,11 +43,13 @@ export class ComponentFactoryResolver extends viewEngine_ComponentFactoryResolve
|
||||
/**
|
||||
* @param ngModule The NgModuleRef to which all resolved factories are bound.
|
||||
*/
|
||||
constructor(private ngModule?: viewEngine_NgModuleRef<any>) { super(); }
|
||||
constructor(private ngModule?: viewEngine_NgModuleRef<any>) {
|
||||
super();
|
||||
}
|
||||
|
||||
resolveComponentFactory<T>(component: Type<T>): viewEngine_ComponentFactory<T> {
|
||||
ngDevMode && assertComponentType(component);
|
||||
const componentDef = getComponentDef(component) !;
|
||||
const componentDef = getComponentDef(component)!;
|
||||
return new ComponentFactory(componentDef, this.ngModule);
|
||||
}
|
||||
}
|
||||
@ -79,7 +81,7 @@ export const SCHEDULER = new InjectionToken<((fn: () => void) => void)>('SCHEDUL
|
||||
|
||||
function createChainedInjector(rootViewInjector: Injector, moduleInjector: Injector): Injector {
|
||||
return {
|
||||
get: <T>(token: Type<T>| InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): T => {
|
||||
get: <T>(token: Type<T>|InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): T => {
|
||||
const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as T, flags);
|
||||
|
||||
if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
|
||||
@ -205,8 +207,9 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
|
||||
// projectable nodes can be passed as array of arrays or an array of iterables (ngUpgrade
|
||||
// case). Here we do normalize passed data structure to be an array of arrays to avoid
|
||||
// complex checks down the line.
|
||||
tElementNode.projection =
|
||||
projectableNodes.map((nodesforSlot: RNode[]) => { return Array.from(nodesforSlot); });
|
||||
tElementNode.projection = projectableNodes.map((nodesforSlot: RNode[]) => {
|
||||
return Array.from(nodesforSlot);
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
|
||||
@ -227,7 +230,7 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
|
||||
if (!rootSelectorOrNode || isIsolated) {
|
||||
// The host element of the internal or isolated root view is attached to the component's host
|
||||
// view node.
|
||||
componentRef.hostView._tViewNode !.child = tElementNode;
|
||||
componentRef.hostView._tViewNode!.child = tElementNode;
|
||||
}
|
||||
return componentRef;
|
||||
}
|
||||
@ -272,7 +275,9 @@ export class ComponentRef<T> extends viewEngine_ComponentRef<T> {
|
||||
this.componentType = componentType;
|
||||
}
|
||||
|
||||
get injector(): Injector { return new NodeInjector(this._tNode, this._rootLView); }
|
||||
get injector(): Injector {
|
||||
return new NodeInjector(this._tNode, this._rootLView);
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
if (this.destroyCbs) {
|
||||
|
@ -18,7 +18,8 @@ import {getComponentLViewByIndex, getNativeByTNodeOrNull, readPatchedData, unwra
|
||||
|
||||
|
||||
|
||||
/** Returns the matching `LContext` data for a given DOM node, directive or component instance.
|
||||
/**
|
||||
* Returns the matching `LContext` data for a given DOM node, directive or component instance.
|
||||
*
|
||||
* This function will examine the provided DOM element, component, or directive instance\'s
|
||||
* monkey-patched property to derive the `LContext` data. Once called then the monkey-patched
|
||||
@ -43,7 +44,7 @@ export function getLContext(target: any): LContext|null {
|
||||
// only when it's an array is it considered an LView instance
|
||||
// ... otherwise it's an already constructed LContext instance
|
||||
if (Array.isArray(mpValue)) {
|
||||
const lView: LView = mpValue !;
|
||||
const lView: LView = mpValue!;
|
||||
let nodeIndex: number;
|
||||
let component: any = undefined;
|
||||
let directives: any[]|null|undefined = undefined;
|
||||
@ -173,7 +174,7 @@ export function getComponentViewByInstance(componentInstance: {}): LView {
|
||||
* Assigns the given data to the given target (which could be a component,
|
||||
* directive or DOM node instance) using monkey-patching.
|
||||
*/
|
||||
export function attachPatchData(target: any, data: LView | LContext) {
|
||||
export function attachPatchData(target: any, data: LView|LContext) {
|
||||
target[MONKEY_PATCH_KEY_NAME] = data;
|
||||
}
|
||||
|
||||
@ -191,7 +192,7 @@ export function isDirectiveInstance(instance: any): boolean {
|
||||
function findViaNativeElement(lView: LView, target: RElement): number {
|
||||
let tNode = lView[TVIEW].firstChild;
|
||||
while (tNode) {
|
||||
const native = getNativeByTNodeOrNull(tNode, lView) !;
|
||||
const native = getNativeByTNodeOrNull(tNode, lView)!;
|
||||
if (native === target) {
|
||||
return tNode.index;
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||
decls: componentDefinition.decls,
|
||||
vars: componentDefinition.vars,
|
||||
factory: null,
|
||||
template: componentDefinition.template || null !,
|
||||
template: componentDefinition.template || null!,
|
||||
consts: componentDefinition.consts || null,
|
||||
ngContentSelectors: componentDefinition.ngContentSelectors,
|
||||
hostBindings: componentDefinition.hostBindings || null,
|
||||
@ -311,8 +311,8 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||
hostAttrs: componentDefinition.hostAttrs || null,
|
||||
contentQueries: componentDefinition.contentQueries || null,
|
||||
declaredInputs: declaredInputs,
|
||||
inputs: null !, // assigned in noSideEffects
|
||||
outputs: null !, // assigned in noSideEffects
|
||||
inputs: null!, // assigned in noSideEffects
|
||||
outputs: null!, // assigned in noSideEffects
|
||||
exportAs: componentDefinition.exportAs || null,
|
||||
onChanges: null,
|
||||
onInit: typePrototype.ngOnInit || null,
|
||||
@ -323,8 +323,8 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||
afterViewChecked: typePrototype.ngAfterViewChecked || null,
|
||||
onDestroy: typePrototype.ngOnDestroy || null,
|
||||
onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
|
||||
directiveDefs: null !, // assigned in noSideEffects
|
||||
pipeDefs: null !, // assigned in noSideEffects
|
||||
directiveDefs: null!, // assigned in noSideEffects
|
||||
pipeDefs: null!, // assigned in noSideEffects
|
||||
selectors: componentDefinition.selectors || EMPTY_ARRAY,
|
||||
viewQuery: componentDefinition.viewQuery || null,
|
||||
features: componentDefinition.features as DirectiveDefFeature[] || null,
|
||||
@ -339,9 +339,9 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||
schemas: componentDefinition.schemas || null,
|
||||
tView: null,
|
||||
};
|
||||
const directiveTypes = componentDefinition.directives !;
|
||||
const directiveTypes = componentDefinition.directives!;
|
||||
const feature = componentDefinition.features;
|
||||
const pipeTypes = componentDefinition.pipes !;
|
||||
const pipeTypes = componentDefinition.pipes!;
|
||||
def.id += _renderCompCount++;
|
||||
def.inputs = invertObject(componentDefinition.inputs, declaredInputs),
|
||||
def.outputs = invertObject(componentDefinition.outputs),
|
||||
@ -373,7 +373,7 @@ export function extractDirectiveDef(type: Type<any>): DirectiveDef<any>|Componen
|
||||
if (ngDevMode && !def) {
|
||||
throw new Error(`'${type.name}' is neither 'ComponentType' or 'DirectiveType'.`);
|
||||
}
|
||||
return def !;
|
||||
return def!;
|
||||
}
|
||||
|
||||
export function extractPipeDef(type: Type<any>): PipeDef<any> {
|
||||
@ -381,7 +381,7 @@ export function extractPipeDef(type: Type<any>): PipeDef<any> {
|
||||
if (ngDevMode && !def) {
|
||||
throw new Error(`'${type.name}' is not a 'PipeType'.`);
|
||||
}
|
||||
return def !;
|
||||
return def!;
|
||||
}
|
||||
|
||||
export const autoRegisterModuleById: {[id: string]: NgModuleType} = {};
|
||||
@ -425,8 +425,9 @@ export function ɵɵdefineNgModule<T>(def: {
|
||||
id: def.id || null,
|
||||
};
|
||||
if (def.id != null) {
|
||||
noSideEffects(
|
||||
() => { autoRegisterModuleById[def.id !] = def.type as unknown as NgModuleType; });
|
||||
noSideEffects(() => {
|
||||
autoRegisterModuleById[def.id!] = def.type as unknown as NgModuleType;
|
||||
});
|
||||
}
|
||||
return res as never;
|
||||
}
|
||||
@ -443,7 +444,7 @@ export function ɵɵdefineNgModule<T>(def: {
|
||||
*/
|
||||
export function ɵɵsetNgModuleScope(type: any, scope: {
|
||||
/** List of components, directives, and pipes declared by this module. */
|
||||
declarations?: Type<any>[] | (() => Type<any>[]);
|
||||
declarations?: Type<any>[]|(() => Type<any>[]);
|
||||
|
||||
/** List of modules or `ModuleWithProviders` imported by this module. */
|
||||
imports?: Type<any>[] | (() => Type<any>[]);
|
||||
@ -455,11 +456,11 @@ export function ɵɵsetNgModuleScope(type: any, scope: {
|
||||
exports?: Type<any>[] | (() => Type<any>[]);
|
||||
}): void {
|
||||
return noSideEffects(() => {
|
||||
const ngModuleDef = getNgModuleDef(type, true);
|
||||
ngModuleDef.declarations = scope.declarations || EMPTY_ARRAY;
|
||||
ngModuleDef.imports = scope.imports || EMPTY_ARRAY;
|
||||
ngModuleDef.exports = scope.exports || EMPTY_ARRAY;
|
||||
}) as never;
|
||||
const ngModuleDef = getNgModuleDef(type, true);
|
||||
ngModuleDef.declarations = scope.declarations || EMPTY_ARRAY;
|
||||
ngModuleDef.imports = scope.imports || EMPTY_ARRAY;
|
||||
ngModuleDef.exports = scope.exports || EMPTY_ARRAY;
|
||||
}) as never;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -518,13 +519,13 @@ export function ɵɵsetNgModuleScope(type: any, scope: {
|
||||
|
||||
*/
|
||||
function invertObject<T>(
|
||||
obj?: {[P in keyof T]?: string | [string, string]},
|
||||
obj?: {[P in keyof T]?: string|[string, string]},
|
||||
secondary?: {[key: string]: string}): {[P in keyof T]: string} {
|
||||
if (obj == null) return EMPTY_OBJ as any;
|
||||
const newLookup: any = {};
|
||||
for (const minifiedKey in obj) {
|
||||
if (obj.hasOwnProperty(minifiedKey)) {
|
||||
let publicName: string|[string, string] = obj[minifiedKey] !;
|
||||
let publicName: string|[string, string] = obj[minifiedKey]!;
|
||||
let declaredName = publicName;
|
||||
if (Array.isArray(publicName)) {
|
||||
declaredName = publicName[1];
|
||||
@ -555,142 +556,143 @@ function invertObject<T>(
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export const ɵɵdefineDirective = ɵɵdefineComponent as any as<T>(directiveDefinition: {
|
||||
/**
|
||||
* Directive type, needed to configure the injector.
|
||||
*/
|
||||
type: Type<T>;
|
||||
export const ɵɵdefineDirective =
|
||||
ɵɵdefineComponent as any as<T>(directiveDefinition: {
|
||||
/**
|
||||
* Directive type, needed to configure the injector.
|
||||
*/
|
||||
type: Type<T>;
|
||||
|
||||
/** The selectors that will be used to match nodes to this directive. */
|
||||
selectors?: CssSelectorList;
|
||||
/** The selectors that will be used to match nodes to this directive. */
|
||||
selectors?: CssSelectorList;
|
||||
|
||||
/**
|
||||
* A map of input names.
|
||||
*
|
||||
* The format is in: `{[actualPropertyName: string]:(string|[string, string])}`.
|
||||
*
|
||||
* Given:
|
||||
* ```
|
||||
* class MyComponent {
|
||||
* @Input()
|
||||
* publicInput1: string;
|
||||
*
|
||||
* @Input('publicInput2')
|
||||
* declaredInput2: string;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* is described as:
|
||||
* ```
|
||||
* {
|
||||
* publicInput1: 'publicInput1',
|
||||
* declaredInput2: ['declaredInput2', 'publicInput2'],
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Which the minifier may translate to:
|
||||
* ```
|
||||
* {
|
||||
* minifiedPublicInput1: 'publicInput1',
|
||||
* minifiedDeclaredInput2: [ 'publicInput2', 'declaredInput2'],
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* This allows the render to re-construct the minified, public, and declared names
|
||||
* of properties.
|
||||
*
|
||||
* NOTE:
|
||||
* - Because declared and public name are usually same we only generate the array
|
||||
* `['declared', 'public']` format when they differ.
|
||||
* - The reason why this API and `outputs` API is not the same is that `NgOnChanges` has
|
||||
* inconsistent behavior in that it uses declared names rather than minified or public. For
|
||||
* this reason `NgOnChanges` will be deprecated and removed in future version and this
|
||||
* API will be simplified to be consistent with `output`.
|
||||
*/
|
||||
inputs?: {[P in keyof T]?: string | [string, string]};
|
||||
/**
|
||||
* A map of input names.
|
||||
*
|
||||
* The format is in: `{[actualPropertyName: string]:(string|[string, string])}`.
|
||||
*
|
||||
* Given:
|
||||
* ```
|
||||
* class MyComponent {
|
||||
* @Input()
|
||||
* publicInput1: string;
|
||||
*
|
||||
* @Input('publicInput2')
|
||||
* declaredInput2: string;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* is described as:
|
||||
* ```
|
||||
* {
|
||||
* publicInput1: 'publicInput1',
|
||||
* declaredInput2: ['declaredInput2', 'publicInput2'],
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Which the minifier may translate to:
|
||||
* ```
|
||||
* {
|
||||
* minifiedPublicInput1: 'publicInput1',
|
||||
* minifiedDeclaredInput2: [ 'publicInput2', 'declaredInput2'],
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* This allows the render to re-construct the minified, public, and declared names
|
||||
* of properties.
|
||||
*
|
||||
* NOTE:
|
||||
* - Because declared and public name are usually same we only generate the array
|
||||
* `['declared', 'public']` format when they differ.
|
||||
* - The reason why this API and `outputs` API is not the same is that `NgOnChanges` has
|
||||
* inconsistent behavior in that it uses declared names rather than minified or public. For
|
||||
* this reason `NgOnChanges` will be deprecated and removed in future version and this
|
||||
* API will be simplified to be consistent with `output`.
|
||||
*/
|
||||
inputs?: {[P in keyof T]?: string | [string, string]};
|
||||
|
||||
/**
|
||||
* A map of output names.
|
||||
*
|
||||
* The format is in: `{[actualPropertyName: string]:string}`.
|
||||
*
|
||||
* Which the minifier may translate to: `{[minifiedPropertyName: string]:string}`.
|
||||
*
|
||||
* This allows the render to re-construct the minified and non-minified names
|
||||
* of properties.
|
||||
*/
|
||||
outputs?: {[P in keyof T]?: string};
|
||||
/**
|
||||
* A map of output names.
|
||||
*
|
||||
* The format is in: `{[actualPropertyName: string]:string}`.
|
||||
*
|
||||
* Which the minifier may translate to: `{[minifiedPropertyName: string]:string}`.
|
||||
*
|
||||
* This allows the render to re-construct the minified and non-minified names
|
||||
* of properties.
|
||||
*/
|
||||
outputs?: {[P in keyof T]?: string};
|
||||
|
||||
/**
|
||||
* A list of optional features to apply.
|
||||
*
|
||||
* See: {@link NgOnChangesFeature}, {@link ProvidersFeature}, {@link InheritDefinitionFeature}
|
||||
*/
|
||||
features?: DirectiveDefFeature[];
|
||||
/**
|
||||
* A list of optional features to apply.
|
||||
*
|
||||
* See: {@link NgOnChangesFeature}, {@link ProvidersFeature}, {@link InheritDefinitionFeature}
|
||||
*/
|
||||
features?: DirectiveDefFeature[];
|
||||
|
||||
/**
|
||||
* Function executed by the parent template to allow child directive to apply host bindings.
|
||||
*/
|
||||
hostBindings?: HostBindingsFunction<T>;
|
||||
/**
|
||||
* Function executed by the parent template to allow child directive to apply host bindings.
|
||||
*/
|
||||
hostBindings?: HostBindingsFunction<T>;
|
||||
|
||||
/**
|
||||
* The number of bindings in this directive `hostBindings` (including pure fn bindings).
|
||||
*
|
||||
* Used to calculate the length of the component's LView array, so we
|
||||
* can pre-fill the array and set the host binding start index.
|
||||
*/
|
||||
hostVars?: number;
|
||||
/**
|
||||
* The number of bindings in this directive `hostBindings` (including pure fn bindings).
|
||||
*
|
||||
* Used to calculate the length of the component's LView array, so we
|
||||
* can pre-fill the array and set the host binding start index.
|
||||
*/
|
||||
hostVars?: number;
|
||||
|
||||
/**
|
||||
* Assign static attribute values to a host element.
|
||||
*
|
||||
* This property will assign static attribute values as well as class and style
|
||||
* values to a host element. Since attribute values can consist of different types of values, the
|
||||
* `hostAttrs` array must include the values in the following format:
|
||||
*
|
||||
* attrs = [
|
||||
* // static attributes (like `title`, `name`, `id`...)
|
||||
* attr1, value1, attr2, value,
|
||||
*
|
||||
* // a single namespace value (like `x:id`)
|
||||
* NAMESPACE_MARKER, namespaceUri1, name1, value1,
|
||||
*
|
||||
* // another single namespace value (like `x:name`)
|
||||
* NAMESPACE_MARKER, namespaceUri2, name2, value2,
|
||||
*
|
||||
* // a series of CSS classes that will be applied to the element (no spaces)
|
||||
* CLASSES_MARKER, class1, class2, class3,
|
||||
*
|
||||
* // a series of CSS styles (property + value) that will be applied to the element
|
||||
* STYLES_MARKER, prop1, value1, prop2, value2
|
||||
* ]
|
||||
*
|
||||
* All non-class and non-style attributes must be defined at the start of the list
|
||||
* first before all class and style values are set. When there is a change in value
|
||||
* type (like when classes and styles are introduced) a marker must be used to separate
|
||||
* the entries. The marker values themselves are set via entries found in the
|
||||
* [AttributeMarker] enum.
|
||||
*/
|
||||
hostAttrs?: TAttributes;
|
||||
/**
|
||||
* Assign static attribute values to a host element.
|
||||
*
|
||||
* This property will assign static attribute values as well as class and style
|
||||
* values to a host element. Since attribute values can consist of different types of values,
|
||||
* the `hostAttrs` array must include the values in the following format:
|
||||
*
|
||||
* attrs = [
|
||||
* // static attributes (like `title`, `name`, `id`...)
|
||||
* attr1, value1, attr2, value,
|
||||
*
|
||||
* // a single namespace value (like `x:id`)
|
||||
* NAMESPACE_MARKER, namespaceUri1, name1, value1,
|
||||
*
|
||||
* // another single namespace value (like `x:name`)
|
||||
* NAMESPACE_MARKER, namespaceUri2, name2, value2,
|
||||
*
|
||||
* // a series of CSS classes that will be applied to the element (no spaces)
|
||||
* CLASSES_MARKER, class1, class2, class3,
|
||||
*
|
||||
* // a series of CSS styles (property + value) that will be applied to the element
|
||||
* STYLES_MARKER, prop1, value1, prop2, value2
|
||||
* ]
|
||||
*
|
||||
* All non-class and non-style attributes must be defined at the start of the list
|
||||
* first before all class and style values are set. When there is a change in value
|
||||
* type (like when classes and styles are introduced) a marker must be used to separate
|
||||
* the entries. The marker values themselves are set via entries found in the
|
||||
* [AttributeMarker] enum.
|
||||
*/
|
||||
hostAttrs?: TAttributes;
|
||||
|
||||
/**
|
||||
* Function to create instances of content queries associated with a given directive.
|
||||
*/
|
||||
contentQueries?: ContentQueriesFunction<T>;
|
||||
/**
|
||||
* Function to create instances of content queries associated with a given directive.
|
||||
*/
|
||||
contentQueries?: ContentQueriesFunction<T>;
|
||||
|
||||
/**
|
||||
* Additional set of instructions specific to view query processing. This could be seen as a
|
||||
* set of instructions to be inserted into the template function.
|
||||
*/
|
||||
viewQuery?: ViewQueriesFunction<T>| null;
|
||||
/**
|
||||
* Additional set of instructions specific to view query processing. This could be seen as a
|
||||
* set of instructions to be inserted into the template function.
|
||||
*/
|
||||
viewQuery?: ViewQueriesFunction<T>| null;
|
||||
|
||||
/**
|
||||
* Defines the name that can be used in the template to assign this directive to a variable.
|
||||
*
|
||||
* See: {@link Directive.exportAs}
|
||||
*/
|
||||
exportAs?: string[];
|
||||
}) => never;
|
||||
/**
|
||||
* Defines the name that can be used in the template to assign this directive to a variable.
|
||||
*
|
||||
* See: {@link Directive.exportAs}
|
||||
*/
|
||||
exportAs?: string[];
|
||||
}) => never;
|
||||
|
||||
/**
|
||||
* Create a pipe definition object.
|
||||
@ -719,12 +721,12 @@ export function ɵɵdefinePipe<T>(pipeDef: {
|
||||
pure?: boolean
|
||||
}): never {
|
||||
return (<PipeDef<T>>{
|
||||
type: pipeDef.type,
|
||||
name: pipeDef.name,
|
||||
factory: null,
|
||||
pure: pipeDef.pure !== false,
|
||||
onDestroy: pipeDef.type.prototype.ngOnDestroy || null
|
||||
}) as never;
|
||||
type: pipeDef.type,
|
||||
name: pipeDef.name,
|
||||
factory: null,
|
||||
pure: pipeDef.pure !== false,
|
||||
onDestroy: pipeDef.type.prototype.ngOnDestroy || null
|
||||
}) as never;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,10 +21,10 @@ import {getFactoryDef} from './definition';
|
||||
import {NG_ELEMENT_ID, NG_FACTORY_DEF} from './fields';
|
||||
import {registerPreOrderHooks} from './hooks';
|
||||
import {DirectiveDef, FactoryFn} from './interfaces/definition';
|
||||
import {NO_PARENT_INJECTOR, NodeInjectorFactory, PARENT_INJECTOR, RelativeInjectorLocation, RelativeInjectorLocationFlags, TNODE, isFactory} from './interfaces/injector';
|
||||
import {isFactory, NO_PARENT_INJECTOR, NodeInjectorFactory, PARENT_INJECTOR, RelativeInjectorLocation, RelativeInjectorLocationFlags, TNODE} from './interfaces/injector';
|
||||
import {AttributeMarker, TContainerNode, TDirectiveHostNode, TElementContainerNode, TElementNode, TNode, TNodeProviderIndexes, TNodeType} from './interfaces/node';
|
||||
import {isComponentDef, isComponentHost} from './interfaces/type_checks';
|
||||
import {DECLARATION_COMPONENT_VIEW, DECLARATION_VIEW, INJECTOR, LView, TData, TVIEW, TView, T_HOST} from './interfaces/view';
|
||||
import {DECLARATION_COMPONENT_VIEW, DECLARATION_VIEW, INJECTOR, LView, T_HOST, TData, TVIEW, TView} from './interfaces/view';
|
||||
import {assertNodeOfPossibleTypes} from './node_assert';
|
||||
import {enterDI, leaveDI} from './state';
|
||||
import {isNameOnlyAttributeMarker} from './util/attrs_utils';
|
||||
@ -97,7 +97,7 @@ let nextNgElementId = 0;
|
||||
* @param type The directive token to register
|
||||
*/
|
||||
export function bloomAdd(
|
||||
injectorIndex: number, tView: TView, type: Type<any>| InjectionToken<any>| string): void {
|
||||
injectorIndex: number, tView: TView, type: Type<any>|InjectionToken<any>|string): void {
|
||||
ngDevMode && assertEqual(tView.firstCreatePass, true, 'expected firstCreatePass to be true');
|
||||
let id: number|undefined =
|
||||
typeof type !== 'string' ? (type as any)[NG_ELEMENT_ID] : type.charCodeAt(0) || 0;
|
||||
@ -141,7 +141,7 @@ export function bloomAdd(
|
||||
* @returns Node injector
|
||||
*/
|
||||
export function getOrCreateNodeInjectorForNode(
|
||||
tNode: TElementNode | TContainerNode | TElementContainerNode, hostView: LView): number {
|
||||
tNode: TElementNode|TContainerNode|TElementContainerNode, hostView: LView): number {
|
||||
const existingInjectorIndex = getInjectorIndex(tNode, hostView);
|
||||
if (existingInjectorIndex !== -1) {
|
||||
return existingInjectorIndex;
|
||||
@ -175,7 +175,7 @@ export function getOrCreateNodeInjectorForNode(
|
||||
return injectorIndex;
|
||||
}
|
||||
|
||||
function insertBloom(arr: any[], footer: TNode | null): void {
|
||||
function insertBloom(arr: any[], footer: TNode|null): void {
|
||||
arr.push(0, 0, 0, 0, 0, 0, 0, 0, footer);
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ export function getParentInjectorLocation(tNode: TNode, view: LView): RelativeIn
|
||||
let hostTNode = view[T_HOST];
|
||||
let viewOffset = 1;
|
||||
while (hostTNode && hostTNode.injectorIndex === -1) {
|
||||
view = view[DECLARATION_VIEW] !;
|
||||
view = view[DECLARATION_VIEW]!;
|
||||
hostTNode = view ? view[T_HOST] : null;
|
||||
viewOffset++;
|
||||
}
|
||||
@ -229,7 +229,7 @@ export function getParentInjectorLocation(tNode: TNode, view: LView): RelativeIn
|
||||
* @param token The type or the injection token to be made public
|
||||
*/
|
||||
export function diPublicInInjector(
|
||||
injectorIndex: number, tView: TView, token: InjectionToken<any>| Type<any>): void {
|
||||
injectorIndex: number, tView: TView, token: InjectionToken<any>|Type<any>): void {
|
||||
bloomAdd(injectorIndex, tView, token);
|
||||
}
|
||||
|
||||
@ -265,8 +265,9 @@ export function diPublicInInjector(
|
||||
* @publicApi
|
||||
*/
|
||||
export function injectAttributeImpl(tNode: TNode, attrNameToInject: string): string|null {
|
||||
ngDevMode && assertNodeOfPossibleTypes(
|
||||
tNode, TNodeType.Container, TNodeType.Element, TNodeType.ElementContainer);
|
||||
ngDevMode &&
|
||||
assertNodeOfPossibleTypes(
|
||||
tNode, TNodeType.Container, TNodeType.Element, TNodeType.ElementContainer);
|
||||
ngDevMode && assertDefined(tNode, 'expecting tNode');
|
||||
if (attrNameToInject === 'class') {
|
||||
return tNode.classes;
|
||||
@ -327,7 +328,7 @@ export function injectAttributeImpl(tNode: TNode, attrNameToInject: string): str
|
||||
* @returns the value from the injector, `null` when not found, or `notFoundValue` if provided
|
||||
*/
|
||||
export function getOrCreateInjectable<T>(
|
||||
tNode: TDirectiveHostNode | null, lView: LView, token: Type<T>| InjectionToken<T>,
|
||||
tNode: TDirectiveHostNode|null, lView: LView, token: Type<T>|InjectionToken<T>,
|
||||
flags: InjectFlags = InjectFlags.Default, notFoundValue?: any): T|null {
|
||||
if (tNode !== null) {
|
||||
const bloomHash = bloomHashBitOrFactory(token);
|
||||
@ -443,8 +444,8 @@ export function getOrCreateInjectable<T>(
|
||||
const NOT_FOUND = {};
|
||||
|
||||
function searchTokensOnInjector<T>(
|
||||
injectorIndex: number, lView: LView, token: Type<T>| InjectionToken<T>,
|
||||
previousTView: TView | null, flags: InjectFlags, hostTElementNode: TNode | null) {
|
||||
injectorIndex: number, lView: LView, token: Type<T>|InjectionToken<T>,
|
||||
previousTView: TView|null, flags: InjectFlags, hostTElementNode: TNode|null) {
|
||||
const currentTView = lView[TVIEW];
|
||||
const tNode = currentTView.data[injectorIndex + TNODE] as TNode;
|
||||
// First, we need to determine if view providers can be accessed by the starting element.
|
||||
@ -490,8 +491,8 @@ function searchTokensOnInjector<T>(
|
||||
* @returns Index of a found directive or provider, or null when none found.
|
||||
*/
|
||||
export function locateDirectiveOrProvider<T>(
|
||||
tNode: TNode, tView: TView, token: Type<T>| InjectionToken<T>, canAccessViewProviders: boolean,
|
||||
isHostSpecialCase: boolean | number): number|null {
|
||||
tNode: TNode, tView: TView, token: Type<T>|InjectionToken<T>, canAccessViewProviders: boolean,
|
||||
isHostSpecialCase: boolean|number): number|null {
|
||||
const nodeProviderIndexes = tNode.providerIndexes;
|
||||
const tInjectables = tView.data;
|
||||
|
||||
@ -521,12 +522,12 @@ export function locateDirectiveOrProvider<T>(
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve or instantiate the injectable from the `LView` at particular `index`.
|
||||
*
|
||||
* This function checks to see if the value has already been instantiated and if so returns the
|
||||
* cached `injectable`. Otherwise if it detects that the value is still a factory it
|
||||
* instantiates the `injectable` and caches the value.
|
||||
*/
|
||||
* Retrieve or instantiate the injectable from the `LView` at particular `index`.
|
||||
*
|
||||
* This function checks to see if the value has already been instantiated and if so returns the
|
||||
* cached `injectable`. Otherwise if it detects that the value is still a factory it
|
||||
* instantiates the `injectable` and caches the value.
|
||||
*/
|
||||
export function getNodeInjectable(
|
||||
lView: LView, tView: TView, index: number, tNode: TDirectiveHostNode): any {
|
||||
let value = lView[index];
|
||||
@ -577,8 +578,8 @@ export function getNodeInjectable(
|
||||
* @returns the matching bit to check in the bloom filter or `null` if the token is not known.
|
||||
* When the returned value is negative then it represents special values such as `Injector`.
|
||||
*/
|
||||
export function bloomHashBitOrFactory(token: Type<any>| InjectionToken<any>| string): number|
|
||||
Function|undefined {
|
||||
export function bloomHashBitOrFactory(token: Type<any>|InjectionToken<any>|string): number|Function|
|
||||
undefined {
|
||||
ngDevMode && assertDefined(token, 'token must be defined');
|
||||
if (typeof token === 'string') {
|
||||
return token.charCodeAt(0) || 0;
|
||||
@ -588,8 +589,7 @@ export function bloomHashBitOrFactory(token: Type<any>| InjectionToken<any>| str
|
||||
return (typeof tokenId === 'number' && tokenId > 0) ? tokenId & BLOOM_MASK : tokenId;
|
||||
}
|
||||
|
||||
export function bloomHasToken(
|
||||
bloomHash: number, injectorIndex: number, injectorView: LView | TData) {
|
||||
export function bloomHasToken(bloomHash: number, injectorIndex: number, injectorView: LView|TData) {
|
||||
// Create a mask that targets the specific bit associated with the directive we're looking for.
|
||||
// JS bit operations are 32 bits, so this will be a number between 2^0 and 2^31, corresponding
|
||||
// to bit positions 0 - 31 in a 32 bit integer.
|
||||
@ -639,9 +639,9 @@ export function ɵɵgetFactoryOf<T>(type: Type<any>): FactoryFn<T>|null {
|
||||
|
||||
if (isForwardRef(type)) {
|
||||
return (() => {
|
||||
const factory = ɵɵgetFactoryOf<T>(resolveForwardRef(typeAny));
|
||||
return factory ? factory() : null;
|
||||
}) as any;
|
||||
const factory = ɵɵgetFactoryOf<T>(resolveForwardRef(typeAny));
|
||||
return factory ? factory() : null;
|
||||
}) as any;
|
||||
}
|
||||
|
||||
let factory = getFactoryDef<T>(typeAny);
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {initNgDevMode} from '../util/ng_dev_mode';
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,8 @@ export function throwErrorIfNoChangesMode(
|
||||
creationMode: boolean, oldValue: any, currValue: any, propName?: string): never|void {
|
||||
const field = propName ? ` for '${propName}'` : '';
|
||||
let msg =
|
||||
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${field}: '${oldValue}'. Current value: '${currValue}'.`;
|
||||
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${
|
||||
field}: '${oldValue}'. Current value: '${currValue}'.`;
|
||||
if (creationMode) {
|
||||
msg +=
|
||||
` It seems like the view has been created after its parent and its children have been dirty checked.` +
|
||||
|
@ -64,16 +64,16 @@ const COPY_COMPONENT_FIELDS: Exclude<keyof ComponentDef<unknown>, keyof Directiv
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵCopyDefinitionFeature(definition: DirectiveDef<any>| ComponentDef<any>): void {
|
||||
let superType = getSuperType(definition.type) !;
|
||||
export function ɵɵCopyDefinitionFeature(definition: DirectiveDef<any>|ComponentDef<any>): void {
|
||||
let superType = getSuperType(definition.type)!;
|
||||
|
||||
let superDef: DirectiveDef<any>|ComponentDef<any>|undefined = undefined;
|
||||
if (isComponentDef(definition)) {
|
||||
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
||||
superDef = superType.ɵcmp !;
|
||||
superDef = superType.ɵcmp!;
|
||||
} else {
|
||||
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
||||
superDef = superType.ɵdir !;
|
||||
superDef = superType.ɵdir!;
|
||||
}
|
||||
|
||||
// Needed because `definition` fields are readonly.
|
||||
|
@ -27,7 +27,7 @@ type WritableDef = Writable<DirectiveDef<any>|ComponentDef<any>>;
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵInheritDefinitionFeature(definition: DirectiveDef<any>| ComponentDef<any>): void {
|
||||
export function ɵɵInheritDefinitionFeature(definition: DirectiveDef<any>|ComponentDef<any>): void {
|
||||
let superType = getSuperType(definition.type);
|
||||
let shouldInheritFields = true;
|
||||
const inheritanceChain: WritableDef[] = [definition];
|
||||
|
@ -13,7 +13,7 @@ import {DirectiveDef, DirectiveDefFeature} from '../interfaces/definition';
|
||||
|
||||
const PRIVATE_PREFIX = '__ngOnChanges_';
|
||||
|
||||
type OnChangesExpando = OnChanges & {
|
||||
type OnChangesExpando = OnChanges&{
|
||||
__ngOnChanges_: SimpleChanges|null|undefined;
|
||||
// tslint:disable-next-line:no-any Can hold any value
|
||||
[key: string]: any;
|
||||
@ -45,7 +45,7 @@ type OnChangesExpando = OnChanges & {
|
||||
export function ɵɵNgOnChangesFeature<T>(definition: DirectiveDef<T>): void {
|
||||
if (definition.type.prototype.ngOnChanges) {
|
||||
definition.setInput = ngOnChangesSetInput;
|
||||
(definition as{onChanges: Function}).onChanges = wrapOnChanges();
|
||||
(definition as {onChanges: Function}).onChanges = wrapOnChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,9 +61,9 @@ function wrapOnChanges() {
|
||||
const current = simpleChangesStore && simpleChangesStore.current;
|
||||
|
||||
if (current) {
|
||||
const previous = simpleChangesStore !.previous;
|
||||
const previous = simpleChangesStore!.previous;
|
||||
if (previous === EMPTY_OBJ) {
|
||||
simpleChangesStore !.previous = current;
|
||||
simpleChangesStore!.previous = current;
|
||||
} else {
|
||||
// New changes are copied to the previous store, so that we don't lose history for inputs
|
||||
// which were not changed this time
|
||||
@ -71,7 +71,7 @@ function wrapOnChanges() {
|
||||
previous[key] = current[key];
|
||||
}
|
||||
}
|
||||
simpleChangesStore !.current = null;
|
||||
simpleChangesStore!.current = null;
|
||||
this.ngOnChanges(current);
|
||||
}
|
||||
};
|
||||
@ -84,7 +84,7 @@ function ngOnChangesSetInput<T>(
|
||||
const current = simpleChangesStore.current || (simpleChangesStore.current = {});
|
||||
const previous = simpleChangesStore.previous;
|
||||
|
||||
const declaredName = (this.declaredInputs as{[key: string]: string})[publicName];
|
||||
const declaredName = (this.declaredInputs as {[key: string]: string})[publicName];
|
||||
const previousChange = previous[declaredName];
|
||||
current[declaredName] = new SimpleChange(
|
||||
previousChange && previousChange.currentValue, value, previous === EMPTY_OBJ);
|
||||
|
@ -16,4 +16,4 @@
|
||||
*/
|
||||
|
||||
export {applyChanges} from './util/change_detection_utils';
|
||||
export {Listener, getComponent, getContext, getDirectives, getHostElement, getInjector, getListeners, getOwningComponent, getRootComponents} from './util/discovery_utils';
|
||||
export {getComponent, getContext, getDirectives, getHostElement, getInjector, getListeners, getOwningComponent, getRootComponents, Listener} from './util/discovery_utils';
|
||||
|
@ -79,8 +79,8 @@ export function registerPostOrderHooks(tView: TView, tNode: TNode): void {
|
||||
|
||||
if (directiveDef.afterContentChecked) {
|
||||
(tView.contentHooks || (tView.contentHooks = [])).push(i, directiveDef.afterContentChecked);
|
||||
(tView.contentCheckHooks || (tView.contentCheckHooks = [
|
||||
])).push(i, directiveDef.afterContentChecked);
|
||||
(tView.contentCheckHooks || (tView.contentCheckHooks = []))
|
||||
.push(i, directiveDef.afterContentChecked);
|
||||
}
|
||||
|
||||
if (directiveDef.afterViewInit) {
|
||||
@ -132,7 +132,7 @@ export function registerPostOrderHooks(tView: TView, tNode: TNode): void {
|
||||
* - number: execute hooks only from the saved index until that node index exclusive (pre-order
|
||||
* case, when executing select(number))
|
||||
*/
|
||||
export function executeCheckHooks(lView: LView, hooks: HookData, nodeIndex?: number | null) {
|
||||
export function executeCheckHooks(lView: LView, hooks: HookData, nodeIndex?: number|null) {
|
||||
callHooks(lView, hooks, InitPhaseState.InitPhaseCompleted, nodeIndex);
|
||||
}
|
||||
|
||||
@ -150,10 +150,11 @@ export function executeCheckHooks(lView: LView, hooks: HookData, nodeIndex?: num
|
||||
* case, when executing select(number))
|
||||
*/
|
||||
export function executeInitAndCheckHooks(
|
||||
lView: LView, hooks: HookData, initPhase: InitPhaseState, nodeIndex?: number | null) {
|
||||
ngDevMode && assertNotEqual(
|
||||
initPhase, InitPhaseState.InitPhaseCompleted,
|
||||
'Init pre-order hooks should not be called more than once');
|
||||
lView: LView, hooks: HookData, initPhase: InitPhaseState, nodeIndex?: number|null) {
|
||||
ngDevMode &&
|
||||
assertNotEqual(
|
||||
initPhase, InitPhaseState.InitPhaseCompleted,
|
||||
'Init pre-order hooks should not be called more than once');
|
||||
if ((lView[FLAGS] & LViewFlags.InitPhaseStateMask) === initPhase) {
|
||||
callHooks(lView, hooks, initPhase, nodeIndex);
|
||||
}
|
||||
@ -188,17 +189,18 @@ export function incrementInitPhaseFlags(lView: LView, initPhase: InitPhaseState)
|
||||
*/
|
||||
function callHooks(
|
||||
currentView: LView, arr: HookData, initPhase: InitPhaseState,
|
||||
currentNodeIndex: number | null | undefined): void {
|
||||
ngDevMode && assertEqual(
|
||||
getCheckNoChangesMode(), false,
|
||||
'Hooks should never be run in the check no changes mode.');
|
||||
currentNodeIndex: number|null|undefined): void {
|
||||
ngDevMode &&
|
||||
assertEqual(
|
||||
getCheckNoChangesMode(), false,
|
||||
'Hooks should never be run in the check no changes mode.');
|
||||
const startIndex = currentNodeIndex !== undefined ?
|
||||
(currentView[PREORDER_HOOK_FLAGS] & PreOrderHookFlags.IndexOfTheNextPreOrderHookMaskMask) :
|
||||
0;
|
||||
const nodeIndexLimit = currentNodeIndex != null ? currentNodeIndex : -1;
|
||||
let lastNodeIndexFound = 0;
|
||||
for (let i = startIndex; i < arr.length; i++) {
|
||||
const hook = arr[i + 1] as() => void;
|
||||
const hook = arr[i + 1] as () => void;
|
||||
if (typeof hook === 'number') {
|
||||
lastNodeIndexFound = arr[i] as number;
|
||||
if (currentNodeIndex != null && lastNodeIndexFound >= currentNodeIndex) {
|
||||
@ -229,7 +231,7 @@ function callHooks(
|
||||
*/
|
||||
function callHook(currentView: LView, initPhase: InitPhaseState, arr: HookData, i: number) {
|
||||
const isInitHook = arr[i] < 0;
|
||||
const hook = arr[i + 1] as() => void;
|
||||
const hook = arr[i + 1] as () => void;
|
||||
const directiveIndex = isInitHook ? -arr[i] : arr[i] as number;
|
||||
const directive = currentView[directiveIndex];
|
||||
if (isInitHook) {
|
||||
|
@ -8,11 +8,12 @@
|
||||
import '../util/ng_i18n_closure_mode';
|
||||
|
||||
import {DEFAULT_LOCALE_ID, getPluralCase} from '../i18n/localization';
|
||||
import {SRCSET_ATTRS, URI_ATTRS, VALID_ATTRS, VALID_ELEMENTS, getTemplateContent} from '../sanitization/html_sanitizer';
|
||||
import {getTemplateContent, SRCSET_ATTRS, URI_ATTRS, VALID_ATTRS, VALID_ELEMENTS} from '../sanitization/html_sanitizer';
|
||||
import {InertBodyHelper} from '../sanitization/inert_body';
|
||||
import {_sanitizeUrl, sanitizeSrcset} from '../sanitization/url_sanitizer';
|
||||
import {addAllToArray} from '../util/array_utils';
|
||||
import {assertDataInRange, assertDefined, assertEqual} from '../util/assert';
|
||||
|
||||
import {bindingUpdated} from './bindings';
|
||||
import {attachPatchData} from './context_discovery';
|
||||
import {setDelayProjection} from './instructions/all';
|
||||
@ -25,7 +26,7 @@ import {TElementNode, TIcuContainerNode, TNode, TNodeFlags, TNodeType, TProjecti
|
||||
import {RComment, RElement, RText} from './interfaces/renderer';
|
||||
import {SanitizerFn} from './interfaces/sanitization';
|
||||
import {isLContainer} from './interfaces/type_checks';
|
||||
import {HEADER_OFFSET, LView, RENDERER, TVIEW, TView, T_HOST} from './interfaces/view';
|
||||
import {HEADER_OFFSET, LView, RENDERER, T_HOST, TVIEW, TView} from './interfaces/view';
|
||||
import {appendChild, applyProjection, createTextNode, nativeRemoveNode} from './node_manipulation';
|
||||
import {getBindingIndex, getIsParent, getLView, getPreviousOrParentTNode, getTView, nextBindingIndex, setIsNotParent, setPreviousOrParentTNode} from './state';
|
||||
import {renderStringify} from './util/misc_utils';
|
||||
@ -105,14 +106,14 @@ interface IcuCase {
|
||||
* @param pattern (sub)Pattern to be broken.
|
||||
*
|
||||
*/
|
||||
function extractParts(pattern: string): (string | IcuExpression)[] {
|
||||
function extractParts(pattern: string): (string|IcuExpression)[] {
|
||||
if (!pattern) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let prevPos = 0;
|
||||
const braceStack = [];
|
||||
const results: (string | IcuExpression)[] = [];
|
||||
const results: (string|IcuExpression)[] = [];
|
||||
const braces = /[{}]/g;
|
||||
// lastIndex doesn't get set to 0 so we have to.
|
||||
braces.lastIndex = 0;
|
||||
@ -158,7 +159,7 @@ function extractParts(pattern: string): (string | IcuExpression)[] {
|
||||
*/
|
||||
function parseICUBlock(pattern: string): IcuExpression {
|
||||
const cases = [];
|
||||
const values: (string | IcuExpression)[][] = [];
|
||||
const values: (string|IcuExpression)[][] = [];
|
||||
let icuType = IcuType.plural;
|
||||
let mainBinding = 0;
|
||||
pattern = pattern.replace(ICU_BLOCK_REGEXP, function(str: string, binding: string, type: string) {
|
||||
@ -219,7 +220,8 @@ function removeInnerTemplateTranslation(message: string): string {
|
||||
ngDevMode &&
|
||||
assertEqual(
|
||||
inTemplate, false,
|
||||
`Tag mismatch: unable to find the end of the sub-template in the translation "${message}"`);
|
||||
`Tag mismatch: unable to find the end of the sub-template in the translation "${
|
||||
message}"`);
|
||||
|
||||
res += message.substr(index);
|
||||
return res;
|
||||
@ -263,7 +265,7 @@ export function getTranslationForTemplate(message: string, subTemplateIndex?: nu
|
||||
*/
|
||||
function generateBindingUpdateOpCodes(
|
||||
str: string, destinationNode: number, attrName?: string,
|
||||
sanitizeFn: SanitizerFn | null = null): I18nUpdateOpCodes {
|
||||
sanitizeFn: SanitizerFn|null = null): I18nUpdateOpCodes {
|
||||
const updateOpCodes: I18nUpdateOpCodes = [null, null]; // Alloc space for mask and size
|
||||
const textParts = str.split(BINDING_REGEXP);
|
||||
let mask = 0;
|
||||
@ -508,7 +510,7 @@ function i18nStartFirstPass(
|
||||
}
|
||||
|
||||
function appendI18nNode(
|
||||
tView: TView, tNode: TNode, parentTNode: TNode, previousTNode: TNode | null,
|
||||
tView: TView, tNode: TNode, parentTNode: TNode, previousTNode: TNode|null,
|
||||
lView: LView): TNode {
|
||||
ngDevMode && ngDevMode.rendererMoveNode++;
|
||||
const nextNode = tNode.next;
|
||||
@ -577,7 +579,7 @@ function appendI18nNode(
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵi18nPostprocess(
|
||||
message: string, replacements: {[key: string]: (string | string[])} = {}): string {
|
||||
message: string, replacements: {[key: string]: (string|string[])} = {}): string {
|
||||
/**
|
||||
* Step 1: resolve all multi-value placeholders like [<5B>#5<>|<7C>*1:1<><31>#2:1<>|<7C>#4:1<>]
|
||||
*
|
||||
@ -660,7 +662,7 @@ export function ɵɵi18nPostprocess(
|
||||
if (!list.length) {
|
||||
throw new Error(`i18n postprocess: unmatched ICU - ${match} with key: ${key}`);
|
||||
}
|
||||
return list.shift() !;
|
||||
return list.shift()!;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
@ -687,9 +689,10 @@ export function ɵɵi18nEnd(): void {
|
||||
* See `i18nEnd` above.
|
||||
*/
|
||||
function i18nEndFirstPass(tView: TView, lView: LView) {
|
||||
ngDevMode && assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'i18nEnd should be called before any binding');
|
||||
ngDevMode &&
|
||||
assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'i18nEnd should be called before any binding');
|
||||
|
||||
const rootIndex = i18nIndexStack[i18nIndexStackPointer--];
|
||||
const tI18n = tView.data[rootIndex + HEADER_OFFSET] as TI18n;
|
||||
@ -709,8 +712,9 @@ function i18nEndFirstPass(tView: TView, lView: LView) {
|
||||
}
|
||||
// Check if an element has any local refs and skip them
|
||||
const tNode = getTNode(tView, index);
|
||||
if (tNode && (tNode.type === TNodeType.Container || tNode.type === TNodeType.Element ||
|
||||
tNode.type === TNodeType.ElementContainer) &&
|
||||
if (tNode &&
|
||||
(tNode.type === TNodeType.Container || tNode.type === TNodeType.Element ||
|
||||
tNode.type === TNodeType.ElementContainer) &&
|
||||
tNode.localNames !== null) {
|
||||
// Divide by 2 to get the number of local refs,
|
||||
// since they are stored as an array that also includes directive indexes,
|
||||
@ -725,8 +729,8 @@ function i18nEndFirstPass(tView: TView, lView: LView) {
|
||||
* Creates and stores the dynamic TNode, and unhooks it from the tree for now.
|
||||
*/
|
||||
function createDynamicNodeAtIndex(
|
||||
tView: TView, lView: LView, index: number, type: TNodeType, native: RElement | RText | null,
|
||||
name: string | null): TElementNode|TIcuContainerNode {
|
||||
tView: TView, lView: LView, index: number, type: TNodeType, native: RElement|RText|null,
|
||||
name: string|null): TElementNode|TIcuContainerNode {
|
||||
const previousOrParentTNode = getPreviousOrParentTNode();
|
||||
ngDevMode && assertDataInRange(lView, index + HEADER_OFFSET);
|
||||
lView[index + HEADER_OFFSET] = native;
|
||||
@ -766,16 +770,16 @@ function readCreateOpCodes(
|
||||
if (destinationNodeIndex === index) {
|
||||
// If the destination node is `i18nStart`, we don't have a
|
||||
// top-level node and we should use the host node instead
|
||||
destinationTNode = lView[T_HOST] !;
|
||||
destinationTNode = lView[T_HOST]!;
|
||||
} else {
|
||||
destinationTNode = getTNode(tView, destinationNodeIndex);
|
||||
}
|
||||
ngDevMode &&
|
||||
assertDefined(
|
||||
currentTNode !,
|
||||
currentTNode!,
|
||||
`You need to create or select a node before you can insert it into the DOM`);
|
||||
previousTNode =
|
||||
appendI18nNode(tView, currentTNode !, destinationTNode, previousTNode, lView);
|
||||
appendI18nNode(tView, currentTNode!, destinationTNode, previousTNode, lView);
|
||||
break;
|
||||
case I18nMutateOpCode.Select:
|
||||
// Negative indicies indicate that a given TNode is a sibling node, not a parent node
|
||||
@ -811,9 +815,10 @@ function readCreateOpCodes(
|
||||
case COMMENT_MARKER:
|
||||
const commentValue = createOpCodes[++i] as string;
|
||||
const commentNodeIndex = createOpCodes[++i] as number;
|
||||
ngDevMode && assertEqual(
|
||||
typeof commentValue, 'string',
|
||||
`Expected "${commentValue}" to be a comment node value`);
|
||||
ngDevMode &&
|
||||
assertEqual(
|
||||
typeof commentValue, 'string',
|
||||
`Expected "${commentValue}" to be a comment node value`);
|
||||
const commentRNode = renderer.createComment(commentValue);
|
||||
ngDevMode && ngDevMode.rendererCreateComment++;
|
||||
previousTNode = currentTNode;
|
||||
@ -828,9 +833,10 @@ function readCreateOpCodes(
|
||||
case ELEMENT_MARKER:
|
||||
const tagNameValue = createOpCodes[++i] as string;
|
||||
const elementNodeIndex = createOpCodes[++i] as number;
|
||||
ngDevMode && assertEqual(
|
||||
typeof tagNameValue, 'string',
|
||||
`Expected "${tagNameValue}" to be an element node tag name`);
|
||||
ngDevMode &&
|
||||
assertEqual(
|
||||
typeof tagNameValue, 'string',
|
||||
`Expected "${tagNameValue}" to be an element node tag name`);
|
||||
const elementRNode = renderer.createElement(tagNameValue);
|
||||
ngDevMode && ngDevMode.rendererCreateElement++;
|
||||
previousTNode = currentTNode;
|
||||
@ -850,7 +856,7 @@ function readCreateOpCodes(
|
||||
}
|
||||
|
||||
function readUpdateOpCodes(
|
||||
updateOpCodes: I18nUpdateOpCodes, icus: TIcu[] | null, bindingsStartIndex: number,
|
||||
updateOpCodes: I18nUpdateOpCodes, icus: TIcu[]|null, bindingsStartIndex: number,
|
||||
changeMask: number, tView: TView, lView: LView, bypassCheckBit = false) {
|
||||
let caseCreated = false;
|
||||
for (let i = 0; i < updateOpCodes.length; i++) {
|
||||
@ -887,7 +893,7 @@ function readUpdateOpCodes(
|
||||
break;
|
||||
case I18nUpdateOpCode.IcuSwitch:
|
||||
tIcuIndex = updateOpCodes[++j] as number;
|
||||
tIcu = icus ![tIcuIndex];
|
||||
tIcu = icus![tIcuIndex];
|
||||
icuTNode = getTNode(tView, nodeIndex) as TIcuContainerNode;
|
||||
// If there is an active case, delete the old nodes
|
||||
if (icuTNode.activeCaseIndex !== null) {
|
||||
@ -910,7 +916,7 @@ function readUpdateOpCodes(
|
||||
const activeIndex = nestedIcuTNode.activeCaseIndex;
|
||||
if (activeIndex !== null) {
|
||||
const nestedIcuTIndex = removeOpCode >>> I18nMutateOpCode.SHIFT_REF;
|
||||
const nestedTIcu = icus ![nestedIcuTIndex];
|
||||
const nestedTIcu = icus![nestedIcuTIndex];
|
||||
addAllToArray(nestedTIcu.remove[activeIndex], removeCodes);
|
||||
}
|
||||
break;
|
||||
@ -929,7 +935,7 @@ function readUpdateOpCodes(
|
||||
break;
|
||||
case I18nUpdateOpCode.IcuUpdate:
|
||||
tIcuIndex = updateOpCodes[++j] as number;
|
||||
tIcu = icus ![tIcuIndex];
|
||||
tIcu = icus![tIcuIndex];
|
||||
icuTNode = getTNode(tView, nodeIndex) as TIcuContainerNode;
|
||||
if (icuTNode.activeCaseIndex !== null) {
|
||||
readUpdateOpCodes(
|
||||
@ -1215,7 +1221,7 @@ function parseIcuCase(
|
||||
if (!inertBodyElement) {
|
||||
throw new Error('Unable to generate inert body element');
|
||||
}
|
||||
const wrapper = getTemplateContent(inertBodyElement !) as Element || inertBodyElement;
|
||||
const wrapper = getTemplateContent(inertBodyElement!) as Element || inertBodyElement;
|
||||
const opCodes: IcuCase = {vars: 0, childIcus: [], create: [], remove: [], update: []};
|
||||
parseNodes(wrapper.firstChild, opCodes, parentIndex, nestedIcus, tIcus, expandoStartIndex);
|
||||
return opCodes;
|
||||
@ -1234,7 +1240,7 @@ const NESTED_ICU = /<2F>(\d+)<29>/;
|
||||
* @param expandoStartIndex Expando start index for the current ICU expression
|
||||
*/
|
||||
function parseNodes(
|
||||
currentNode: Node | null, icuCase: IcuCase, parentIndex: number, nestedIcus: IcuExpression[],
|
||||
currentNode: Node|null, icuCase: IcuCase, parentIndex: number, nestedIcus: IcuExpression[],
|
||||
tIcus: TIcu[], expandoStartIndex: number) {
|
||||
if (currentNode) {
|
||||
const nestedIcusToCreate: [IcuExpression, number][] = [];
|
||||
@ -1254,7 +1260,7 @@ function parseNodes(
|
||||
parentIndex << I18nMutateOpCode.SHIFT_PARENT | I18nMutateOpCode.AppendChild);
|
||||
const elAttrs = element.attributes;
|
||||
for (let i = 0; i < elAttrs.length; i++) {
|
||||
const attr = elAttrs.item(i) !;
|
||||
const attr = elAttrs.item(i)!;
|
||||
const lowerAttrName = attr.name.toLowerCase();
|
||||
const hasBinding = !!attr.value.match(BINDING_REGEXP);
|
||||
// we assume the input string is safe, unless it's using a binding
|
||||
@ -1276,8 +1282,8 @@ function parseNodes(
|
||||
}
|
||||
} else {
|
||||
ngDevMode &&
|
||||
console.warn(
|
||||
`WARNING: ignoring unsafe attribute value ${lowerAttrName} on element ${tagName} (see http://g.co/ng/security#xss)`);
|
||||
console.warn(`WARNING: ignoring unsafe attribute value ${
|
||||
lowerAttrName} on element ${tagName} (see http://g.co/ng/security#xss)`);
|
||||
}
|
||||
} else {
|
||||
icuCase.create.push(
|
||||
@ -1324,7 +1330,7 @@ function parseNodes(
|
||||
// We do not handle any other type of element
|
||||
icuCase.vars--;
|
||||
}
|
||||
currentNode = nextNode !;
|
||||
currentNode = nextNode!;
|
||||
}
|
||||
|
||||
for (let i = 0; i < nestedIcusToCreate.length; i++) {
|
||||
|
@ -16,13 +16,14 @@ import {getComponent, getDirectives, getHostElement, getRenderedText} from './ut
|
||||
|
||||
export {ComponentFactory, ComponentFactoryResolver, ComponentRef, injectComponentFactoryResolver} from './component_ref';
|
||||
export {ɵɵgetFactoryOf, ɵɵgetInheritedFactory} from './di';
|
||||
|
||||
export {getLocaleId, setLocaleId, ɵɵi18n, ɵɵi18nApply, ɵɵi18nAttributes, ɵɵi18nEnd, ɵɵi18nExp, ɵɵi18nPostprocess, ɵɵi18nStart,} from './i18n';
|
||||
// clang-format off
|
||||
export {
|
||||
detectChanges,
|
||||
markDirty,
|
||||
store,
|
||||
tick,
|
||||
ɵɵadvance,
|
||||
|
||||
ɵɵattribute,
|
||||
ɵɵattributeInterpolate1,
|
||||
@ -54,7 +55,6 @@ export {
|
||||
ɵɵcontainerRefreshStart,
|
||||
|
||||
ɵɵdirectiveInject,
|
||||
ɵɵinvalidFactory,
|
||||
|
||||
ɵɵelement,
|
||||
ɵɵelementContainer,
|
||||
@ -69,7 +69,9 @@ export {
|
||||
ɵɵembeddedViewStart,
|
||||
|
||||
ɵɵgetCurrentView,
|
||||
ɵɵhostProperty,
|
||||
ɵɵinjectAttribute,
|
||||
ɵɵinvalidFactory,
|
||||
|
||||
ɵɵlistener,
|
||||
|
||||
@ -81,7 +83,6 @@ export {
|
||||
|
||||
ɵɵprojection,
|
||||
ɵɵprojectionDef,
|
||||
ɵɵhostProperty,
|
||||
ɵɵproperty,
|
||||
ɵɵpropertyInterpolate,
|
||||
ɵɵpropertyInterpolate1,
|
||||
@ -98,7 +99,6 @@ export {
|
||||
|
||||
// TODO: remove `select` once we've refactored all of the tests not to use it.
|
||||
ɵɵselect,
|
||||
ɵɵadvance,
|
||||
ɵɵstyleMap,
|
||||
ɵɵstyleMapInterpolate1,
|
||||
ɵɵstyleMapInterpolate2,
|
||||
@ -139,37 +139,14 @@ export {
|
||||
ɵɵupdateSyntheticHostBinding,
|
||||
} from './instructions/all';
|
||||
export {RenderFlags} from './interfaces/definition';
|
||||
export {CssSelectorList, ProjectionSlots} from './interfaces/projection';
|
||||
|
||||
export {
|
||||
ɵɵrestoreView,
|
||||
|
||||
ɵɵenableBindings,
|
||||
ɵɵdisableBindings,
|
||||
} from './state';
|
||||
|
||||
export {
|
||||
ɵɵi18n,
|
||||
ɵɵi18nAttributes,
|
||||
ɵɵi18nExp,
|
||||
ɵɵi18nStart,
|
||||
ɵɵi18nEnd,
|
||||
ɵɵi18nApply,
|
||||
ɵɵi18nPostprocess,
|
||||
getLocaleId,
|
||||
setLocaleId,
|
||||
} from './i18n';
|
||||
|
||||
export {NgModuleFactory, NgModuleRef, NgModuleType} from './ng_module_ref';
|
||||
|
||||
export {
|
||||
AttributeMarker
|
||||
} from './interfaces/node';
|
||||
|
||||
export {CssSelectorList, ProjectionSlots} from './interfaces/projection';
|
||||
export {
|
||||
setClassMetadata,
|
||||
} from './metadata';
|
||||
|
||||
export {NgModuleFactory, NgModuleRef, NgModuleType} from './ng_module_ref';
|
||||
export {
|
||||
ɵɵpipe,
|
||||
ɵɵpipeBind1,
|
||||
@ -178,16 +155,6 @@ export {
|
||||
ɵɵpipeBind4,
|
||||
ɵɵpipeBindV,
|
||||
} from './pipe';
|
||||
|
||||
export {
|
||||
ɵɵqueryRefresh,
|
||||
ɵɵviewQuery,
|
||||
ɵɵstaticViewQuery,
|
||||
ɵɵloadQuery,
|
||||
ɵɵcontentQuery,
|
||||
ɵɵstaticContentQuery
|
||||
} from './query';
|
||||
|
||||
export {
|
||||
ɵɵpureFunction0,
|
||||
ɵɵpureFunction1,
|
||||
@ -200,41 +167,51 @@ export {
|
||||
ɵɵpureFunction8,
|
||||
ɵɵpureFunctionV,
|
||||
} from './pure_function';
|
||||
export {
|
||||
ɵɵcontentQuery,
|
||||
ɵɵloadQuery,
|
||||
ɵɵqueryRefresh,
|
||||
ɵɵstaticContentQuery
|
||||
,
|
||||
ɵɵstaticViewQuery,
|
||||
ɵɵviewQuery} from './query';
|
||||
export {
|
||||
ɵɵdisableBindings,
|
||||
|
||||
export {ɵɵtemplateRefExtractor, ɵɵinjectPipeChangeDetectorRef} from './view_engine_compatibility_prebound';
|
||||
|
||||
export {ɵɵresolveWindow, ɵɵresolveDocument, ɵɵresolveBody} from './util/misc_utils';
|
||||
|
||||
ɵɵenableBindings,
|
||||
ɵɵrestoreView,
|
||||
} from './state';
|
||||
export {NO_CHANGE} from './tokens';
|
||||
export { ɵɵresolveBody, ɵɵresolveDocument,ɵɵresolveWindow} from './util/misc_utils';
|
||||
export { ɵɵinjectPipeChangeDetectorRef,ɵɵtemplateRefExtractor} from './view_engine_compatibility_prebound';
|
||||
// clang-format on
|
||||
|
||||
export {
|
||||
ComponentDef,
|
||||
ɵɵComponentDefWithMeta,
|
||||
ɵɵFactoryDef,
|
||||
ComponentTemplate,
|
||||
ComponentType,
|
||||
DirectiveDef,
|
||||
ɵɵDirectiveDefWithMeta,
|
||||
DirectiveType,
|
||||
ɵɵNgOnChangesFeature,
|
||||
ɵɵCopyDefinitionFeature,
|
||||
ɵɵInheritDefinitionFeature,
|
||||
ɵɵProvidersFeature,
|
||||
PipeDef,
|
||||
ɵɵPipeDefWithMeta,
|
||||
getComponent,
|
||||
getDirectives,
|
||||
getHostElement,
|
||||
getRenderedText,
|
||||
LifecycleHooksFeature,
|
||||
PipeDef,
|
||||
renderComponent,
|
||||
whenRendered,
|
||||
ɵɵComponentDefWithMeta,
|
||||
ɵɵCopyDefinitionFeature,
|
||||
ɵɵdefineComponent,
|
||||
ɵɵdefineDirective,
|
||||
ɵɵdefineNgModule,
|
||||
ɵɵdefinePipe,
|
||||
getHostElement,
|
||||
getComponent,
|
||||
getDirectives,
|
||||
getRenderedText,
|
||||
renderComponent,
|
||||
ɵɵDirectiveDefWithMeta,
|
||||
ɵɵFactoryDef,
|
||||
ɵɵInheritDefinitionFeature,
|
||||
ɵɵNgOnChangesFeature,
|
||||
ɵɵPipeDefWithMeta,
|
||||
ɵɵProvidersFeature,
|
||||
ɵɵsetComponentScope,
|
||||
ɵɵsetNgModuleScope,
|
||||
whenRendered,
|
||||
};
|
||||
|
||||
export {NO_CHANGE} from './tokens';
|
||||
|
@ -19,21 +19,21 @@ import {getCheckNoChangesMode, getLView, getSelectedIndex, getTView, setSelected
|
||||
*
|
||||
* ```ts
|
||||
* (rf: RenderFlags, ctx: any) => {
|
||||
* if (rf & 1) {
|
||||
* text(0, 'Hello');
|
||||
* text(1, 'Goodbye')
|
||||
* element(2, 'div');
|
||||
* }
|
||||
* if (rf & 2) {
|
||||
* advance(2); // Advance twice to the <div>.
|
||||
* property('title', 'test');
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @param delta Number of elements to advance forwards by.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
* if (rf & 1) {
|
||||
* text(0, 'Hello');
|
||||
* text(1, 'Goodbye')
|
||||
* element(2, 'div');
|
||||
* }
|
||||
* if (rf & 2) {
|
||||
* advance(2); // Advance twice to the <div>.
|
||||
* property('title', 'test');
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @param delta Number of elements to advance forwards by.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵadvance(delta: number): void {
|
||||
ngDevMode && assertGreaterThan(delta, 0, 'Can only advance forward');
|
||||
selectIndexInternal(getTView(), getLView(), getSelectedIndex() + delta, getCheckNoChangesMode());
|
||||
|
@ -26,7 +26,7 @@ import {elementAttributeInternal, storePropertyBindingMetadata} from './shared';
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵattribute(
|
||||
name: string, value: any, sanitizer?: SanitizerFn | null,
|
||||
name: string, value: any, sanitizer?: SanitizerFn|null,
|
||||
namespace?: string): typeof ɵɵattribute {
|
||||
const lView = getLView();
|
||||
const bindingIndex = nextBindingIndex();
|
||||
|
@ -130,9 +130,10 @@ export function ɵɵattributeInterpolate3(
|
||||
if (interpolatedValue !== NO_CHANGE) {
|
||||
const tNode = getSelectedTNode();
|
||||
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0,
|
||||
i1, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0, i1,
|
||||
suffix);
|
||||
}
|
||||
return ɵɵattributeInterpolate3;
|
||||
}
|
||||
@ -177,9 +178,10 @@ export function ɵɵattributeInterpolate4(
|
||||
if (interpolatedValue !== NO_CHANGE) {
|
||||
const tNode = getSelectedTNode();
|
||||
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 4, prefix, i0,
|
||||
i1, i2, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 4, prefix, i0, i1, i2,
|
||||
suffix);
|
||||
}
|
||||
return ɵɵattributeInterpolate4;
|
||||
}
|
||||
@ -227,9 +229,10 @@ export function ɵɵattributeInterpolate5(
|
||||
if (interpolatedValue !== NO_CHANGE) {
|
||||
const tNode = getSelectedTNode();
|
||||
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 5, prefix, i0,
|
||||
i1, i2, i3, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 5, prefix, i0, i1, i2,
|
||||
i3, suffix);
|
||||
}
|
||||
return ɵɵattributeInterpolate5;
|
||||
}
|
||||
@ -279,9 +282,10 @@ export function ɵɵattributeInterpolate6(
|
||||
if (interpolatedValue !== NO_CHANGE) {
|
||||
const tNode = getSelectedTNode();
|
||||
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 6, prefix, i0,
|
||||
i1, i2, i3, i4, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 6, prefix, i0, i1, i2,
|
||||
i3, i4, suffix);
|
||||
}
|
||||
return ɵɵattributeInterpolate6;
|
||||
}
|
||||
@ -333,9 +337,10 @@ export function ɵɵattributeInterpolate7(
|
||||
if (interpolatedValue !== NO_CHANGE) {
|
||||
const tNode = getSelectedTNode();
|
||||
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 7, prefix, i0,
|
||||
i1, i2, i3, i4, i5, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 7, prefix, i0, i1, i2,
|
||||
i3, i4, i5, suffix);
|
||||
}
|
||||
return ɵɵattributeInterpolate7;
|
||||
}
|
||||
@ -389,9 +394,10 @@ export function ɵɵattributeInterpolate8(
|
||||
if (interpolatedValue !== NO_CHANGE) {
|
||||
const tNode = getSelectedTNode();
|
||||
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 8, prefix, i0,
|
||||
i1, i2, i3, i4, i5, i6, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 8, prefix, i0, i1, i2,
|
||||
i3, i4, i5, i6, suffix);
|
||||
}
|
||||
return ɵɵattributeInterpolate8;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export function detectChanges(component: {}): void {
|
||||
*/
|
||||
export function markDirty(component: {}): void {
|
||||
ngDevMode && assertDefined(component, 'component');
|
||||
const rootView = markViewDirty(getComponentViewByInstance(component)) !;
|
||||
const rootView = markViewDirty(getComponentViewByInstance(component))!;
|
||||
|
||||
ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
|
||||
scheduleTick(rootView[CONTEXT] as RootContext, RootContextFlags.DetectChanges);
|
||||
|
@ -13,11 +13,12 @@ import {ACTIVE_INDEX, CONTAINER_HEADER_OFFSET, LContainer} from '../interfaces/c
|
||||
import {ComponentTemplate} from '../interfaces/definition';
|
||||
import {LocalRefExtractor, TAttributes, TContainerNode, TNode, TNodeType, TViewNode} from '../interfaces/node';
|
||||
import {isDirectiveHost} from '../interfaces/type_checks';
|
||||
import {FLAGS, HEADER_OFFSET, InitPhaseState, LView, LViewFlags, RENDERER, TView, TViewType, T_HOST} from '../interfaces/view';
|
||||
import {FLAGS, HEADER_OFFSET, InitPhaseState, LView, LViewFlags, RENDERER, T_HOST, TView, TViewType} from '../interfaces/view';
|
||||
import {assertNodeType} from '../node_assert';
|
||||
import {appendChild, removeView} from '../node_manipulation';
|
||||
import {getBindingIndex, getCheckNoChangesMode, getIsParent, getLView, getPreviousOrParentTNode, getTView, setIsNotParent, setPreviousOrParentTNode} from '../state';
|
||||
import {getConstant, getLContainerActiveIndex, load} from '../util/view_utils';
|
||||
|
||||
import {addToViewTree, createDirectivesInstances, createLContainer, createTNode, createTView, getOrCreateTNode, resolveDirectives, saveResolvedLocalsInData} from './shared';
|
||||
|
||||
|
||||
@ -45,9 +46,9 @@ export function ɵɵcontainer(index: number): void {
|
||||
}
|
||||
|
||||
function templateFirstCreatePass(
|
||||
index: number, tView: TView, lView: LView, templateFn: ComponentTemplate<any>| null,
|
||||
decls: number, vars: number, tagName?: string | null, attrsIndex?: number | null,
|
||||
localRefsIndex?: number | null): TContainerNode {
|
||||
index: number, tView: TView, lView: LView, templateFn: ComponentTemplate<any>|null,
|
||||
decls: number, vars: number, tagName?: string|null, attrsIndex?: number|null,
|
||||
localRefsIndex?: number|null): TContainerNode {
|
||||
ngDevMode && assertFirstCreatePass(tView);
|
||||
ngDevMode && ngDevMode.firstCreatePass++;
|
||||
const tViewConsts = tView.consts;
|
||||
@ -94,8 +95,8 @@ function templateFirstCreatePass(
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtemplate(
|
||||
index: number, templateFn: ComponentTemplate<any>| null, decls: number, vars: number,
|
||||
tagName?: string | null, attrsIndex?: number | null, localRefsIndex?: number | null,
|
||||
index: number, templateFn: ComponentTemplate<any>|null, decls: number, vars: number,
|
||||
tagName?: string|null, attrsIndex?: number|null, localRefsIndex?: number|null,
|
||||
localRefExtractor?: LocalRefExtractor) {
|
||||
const lView = getLView();
|
||||
const tView = getTView();
|
||||
@ -172,7 +173,7 @@ export function ɵɵcontainerRefreshEnd(): void {
|
||||
} else {
|
||||
ngDevMode && assertNodeType(previousOrParentTNode, TNodeType.View);
|
||||
ngDevMode && assertHasParent(previousOrParentTNode);
|
||||
previousOrParentTNode = previousOrParentTNode.parent !;
|
||||
previousOrParentTNode = previousOrParentTNode.parent!;
|
||||
setPreviousOrParentTNode(previousOrParentTNode, false);
|
||||
}
|
||||
|
||||
@ -188,11 +189,12 @@ export function ɵɵcontainerRefreshEnd(): void {
|
||||
}
|
||||
|
||||
function containerInternal(
|
||||
tView: TView, lView: LView, nodeIndex: number, tagName: string | null,
|
||||
attrs: TAttributes | null): TContainerNode {
|
||||
ngDevMode && assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'container nodes should be created before any bindings');
|
||||
tView: TView, lView: LView, nodeIndex: number, tagName: string|null,
|
||||
attrs: TAttributes|null): TContainerNode {
|
||||
ngDevMode &&
|
||||
assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'container nodes should be created before any bindings');
|
||||
|
||||
const adjustedIndex = nodeIndex + HEADER_OFFSET;
|
||||
ngDevMode && assertDataInRange(lView, nodeIndex + HEADER_OFFSET);
|
||||
|
@ -37,10 +37,10 @@ import {getLView, getPreviousOrParentTNode} from '../state';
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵdirectiveInject<T>(token: Type<T>| InjectionToken<T>): T;
|
||||
export function ɵɵdirectiveInject<T>(token: Type<T>| InjectionToken<T>, flags: InjectFlags): T;
|
||||
export function ɵɵdirectiveInject<T>(token: Type<T>|InjectionToken<T>): T;
|
||||
export function ɵɵdirectiveInject<T>(token: Type<T>|InjectionToken<T>, flags: InjectFlags): T;
|
||||
export function ɵɵdirectiveInject<T>(
|
||||
token: Type<T>| InjectionToken<T>, flags = InjectFlags.Default): T|null {
|
||||
token: Type<T>|InjectionToken<T>, flags = InjectFlags.Default): T|null {
|
||||
const lView = getLView();
|
||||
// Fall back to inject() if view hasn't been created. This situation can happen in tests
|
||||
// if inject utilities are used before bootstrapping.
|
||||
|
@ -10,23 +10,24 @@ import {assertDataInRange, assertDefined, assertEqual} from '../../util/assert';
|
||||
import {assertFirstCreatePass, assertHasParent} from '../assert';
|
||||
import {attachPatchData} from '../context_discovery';
|
||||
import {registerPostOrderHooks} from '../hooks';
|
||||
import {TAttributes, TElementNode, TNode, TNodeType, hasClassInput, hasStyleInput} from '../interfaces/node';
|
||||
import {hasClassInput, hasStyleInput, TAttributes, TElementNode, TNode, TNodeType} from '../interfaces/node';
|
||||
import {RElement} from '../interfaces/renderer';
|
||||
import {isContentQueryHost, isDirectiveHost} from '../interfaces/type_checks';
|
||||
import {HEADER_OFFSET, LView, RENDERER, TVIEW, TView, T_HOST} from '../interfaces/view';
|
||||
import {HEADER_OFFSET, LView, RENDERER, T_HOST, TVIEW, TView} from '../interfaces/view';
|
||||
import {assertNodeType} from '../node_assert';
|
||||
import {appendChild, writeDirectClass, writeDirectStyle} from '../node_manipulation';
|
||||
import {decreaseElementDepthCount, getBindingIndex, getElementDepthCount, getIsParent, getLView, getNamespace, getPreviousOrParentTNode, getTView, increaseElementDepthCount, setIsNotParent, setPreviousOrParentTNode} from '../state';
|
||||
import {computeStaticStyling} from '../styling/static_styling';
|
||||
import {setUpAttributes} from '../util/attrs_utils';
|
||||
import {getConstant} from '../util/view_utils';
|
||||
|
||||
import {setDirectiveInputsWhichShadowsStyling} from './property';
|
||||
import {createDirectivesInstances, elementCreate, executeContentQueries, getOrCreateTNode, matchingSchemas, resolveDirectives, saveResolvedLocalsInData} from './shared';
|
||||
|
||||
|
||||
function elementStartFirstCreatePass(
|
||||
index: number, tView: TView, lView: LView, native: RElement, name: string,
|
||||
attrsIndex?: number | null, localRefsIndex?: number): TElementNode {
|
||||
attrsIndex?: number|null, localRefsIndex?: number): TElementNode {
|
||||
ngDevMode && assertFirstCreatePass(tView);
|
||||
ngDevMode && ngDevMode.firstCreatePass++;
|
||||
|
||||
@ -64,14 +65,15 @@ function elementStartFirstCreatePass(
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵelementStart(
|
||||
index: number, name: string, attrsIndex?: number | null, localRefsIndex?: number): void {
|
||||
index: number, name: string, attrsIndex?: number|null, localRefsIndex?: number): void {
|
||||
const lView = getLView();
|
||||
const tView = getTView();
|
||||
const adjustedIndex = HEADER_OFFSET + index;
|
||||
|
||||
ngDevMode && assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'elements should be created before any bindings');
|
||||
ngDevMode &&
|
||||
assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'elements should be created before any bindings');
|
||||
ngDevMode && ngDevMode.rendererCreateElement++;
|
||||
ngDevMode && assertDataInRange(lView, adjustedIndex);
|
||||
|
||||
@ -128,7 +130,7 @@ export function ɵɵelementEnd(): void {
|
||||
setIsNotParent();
|
||||
} else {
|
||||
ngDevMode && assertHasParent(getPreviousOrParentTNode());
|
||||
previousOrParentTNode = previousOrParentTNode.parent !;
|
||||
previousOrParentTNode = previousOrParentTNode.parent!;
|
||||
setPreviousOrParentTNode(previousOrParentTNode, false);
|
||||
}
|
||||
|
||||
@ -142,7 +144,7 @@ export function ɵɵelementEnd(): void {
|
||||
if (tView.firstCreatePass) {
|
||||
registerPostOrderHooks(tView, previousOrParentTNode);
|
||||
if (isContentQueryHost(previousOrParentTNode)) {
|
||||
tView.queries !.elementEnd(previousOrParentTNode);
|
||||
tView.queries!.elementEnd(previousOrParentTNode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +168,7 @@ export function ɵɵelementEnd(): void {
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵelement(
|
||||
index: number, name: string, attrsIndex?: number | null, localRefsIndex?: number): void {
|
||||
index: number, name: string, attrsIndex?: number|null, localRefsIndex?: number): void {
|
||||
ɵɵelementStart(index, name, attrsIndex, localRefsIndex);
|
||||
ɵɵelementEnd();
|
||||
}
|
||||
@ -198,11 +200,11 @@ function warnAboutUnknownElement(
|
||||
|
||||
if (isUnknown && !matchingSchemas(tView, lView, tagName)) {
|
||||
let warning = `'${tagName}' is not a known element:\n`;
|
||||
warning +=
|
||||
`1. If '${tagName}' is an Angular component, then verify that it is part of this module.\n`;
|
||||
warning += `1. If '${
|
||||
tagName}' is an Angular component, then verify that it is part of this module.\n`;
|
||||
if (tagName && tagName.indexOf('-') > -1) {
|
||||
warning +=
|
||||
`2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.`;
|
||||
warning += `2. If '${
|
||||
tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.`;
|
||||
} else {
|
||||
warning +=
|
||||
`2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.`;
|
||||
|
@ -11,7 +11,7 @@ import {attachPatchData} from '../context_discovery';
|
||||
import {registerPostOrderHooks} from '../hooks';
|
||||
import {TAttributes, TElementContainerNode, TNodeType} from '../interfaces/node';
|
||||
import {isContentQueryHost, isDirectiveHost} from '../interfaces/type_checks';
|
||||
import {HEADER_OFFSET, LView, RENDERER, TView, T_HOST} from '../interfaces/view';
|
||||
import {HEADER_OFFSET, LView, RENDERER, T_HOST, TView} from '../interfaces/view';
|
||||
import {assertNodeType} from '../node_assert';
|
||||
import {appendChild} from '../node_manipulation';
|
||||
import {getBindingIndex, getIsParent, getLView, getPreviousOrParentTNode, getTView, setIsNotParent, setPreviousOrParentTNode} from '../state';
|
||||
@ -21,7 +21,7 @@ import {getConstant} from '../util/view_utils';
|
||||
import {createDirectivesInstances, executeContentQueries, getOrCreateTNode, resolveDirectives, saveResolvedLocalsInData} from './shared';
|
||||
|
||||
function elementContainerStartFirstCreatePass(
|
||||
index: number, tView: TView, lView: LView, attrsIndex?: number | null,
|
||||
index: number, tView: TView, lView: LView, attrsIndex?: number|null,
|
||||
localRefsIndex?: number): TElementContainerNode {
|
||||
ngDevMode && ngDevMode.firstCreatePass++;
|
||||
|
||||
@ -61,15 +61,16 @@ function elementContainerStartFirstCreatePass(
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵelementContainerStart(
|
||||
index: number, attrsIndex?: number | null, localRefsIndex?: number): void {
|
||||
index: number, attrsIndex?: number|null, localRefsIndex?: number): void {
|
||||
const lView = getLView();
|
||||
const tView = getTView();
|
||||
const adjustedIndex = index + HEADER_OFFSET;
|
||||
|
||||
ngDevMode && assertDataInRange(lView, adjustedIndex);
|
||||
ngDevMode && assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'element containers should be created before any bindings');
|
||||
ngDevMode &&
|
||||
assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'element containers should be created before any bindings');
|
||||
|
||||
const tNode = tView.firstCreatePass ?
|
||||
elementContainerStartFirstCreatePass(index, tView, lView, attrsIndex, localRefsIndex) :
|
||||
@ -104,7 +105,7 @@ export function ɵɵelementContainerEnd(): void {
|
||||
setIsNotParent();
|
||||
} else {
|
||||
ngDevMode && assertHasParent(previousOrParentTNode);
|
||||
previousOrParentTNode = previousOrParentTNode.parent !;
|
||||
previousOrParentTNode = previousOrParentTNode.parent!;
|
||||
setPreviousOrParentTNode(previousOrParentTNode, false);
|
||||
}
|
||||
|
||||
@ -113,7 +114,7 @@ export function ɵɵelementContainerEnd(): void {
|
||||
if (tView.firstCreatePass) {
|
||||
registerPostOrderHooks(tView, previousOrParentTNode);
|
||||
if (isContentQueryHost(previousOrParentTNode)) {
|
||||
tView.queries !.elementEnd(previousOrParentTNode);
|
||||
tView.queries!.elementEnd(previousOrParentTNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,7 +130,7 @@ export function ɵɵelementContainerEnd(): void {
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵelementContainer(
|
||||
index: number, attrsIndex?: number | null, localRefsIndex?: number): void {
|
||||
index: number, attrsIndex?: number|null, localRefsIndex?: number): void {
|
||||
ɵɵelementContainerStart(index, attrsIndex, localRefsIndex);
|
||||
ɵɵelementContainerEnd();
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import {assertLContainerOrUndefined} from '../assert';
|
||||
import {ACTIVE_INDEX, ActiveIndexFlag, CONTAINER_HEADER_OFFSET, LContainer} from '../interfaces/container';
|
||||
import {RenderFlags} from '../interfaces/definition';
|
||||
import {TContainerNode, TNodeType} from '../interfaces/node';
|
||||
import {CONTEXT, LView, LViewFlags, PARENT, TVIEW, TView, TViewType, T_HOST} from '../interfaces/view';
|
||||
import {CONTEXT, LView, LViewFlags, PARENT, T_HOST, TVIEW, TView, TViewType} from '../interfaces/view';
|
||||
import {assertNodeType} from '../node_assert';
|
||||
import {insertView, removeView} from '../node_manipulation';
|
||||
import {enterView, getIsParent, getLView, getPreviousOrParentTNode, getTView, leaveView, setIsParent, setPreviousOrParentTNode} from '../state';
|
||||
@ -34,7 +34,7 @@ export function ɵɵembeddedViewStart(viewBlockId: number, decls: number, vars:
|
||||
const previousOrParentTNode = getPreviousOrParentTNode();
|
||||
// The previous node can be a view node if we are processing an inline for loop
|
||||
const containerTNode = previousOrParentTNode.type === TNodeType.View ?
|
||||
previousOrParentTNode.parent ! :
|
||||
previousOrParentTNode.parent! :
|
||||
previousOrParentTNode;
|
||||
const lContainer = lView[containerTNode.index] as LContainer;
|
||||
|
||||
@ -141,5 +141,5 @@ export function ɵɵembeddedViewEnd(): void {
|
||||
const lContainer = lView[PARENT] as LContainer;
|
||||
ngDevMode && assertLContainerOrUndefined(lContainer);
|
||||
leaveView();
|
||||
setPreviousOrParentTNode(viewHost !, false);
|
||||
setPreviousOrParentTNode(viewHost!, false);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import {elementPropertyInternal, loadComponentRenderer, storePropertyBindingMeta
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵhostProperty<T>(
|
||||
propName: string, value: T, sanitizer?: SanitizerFn | null): typeof ɵɵhostProperty {
|
||||
propName: string, value: T, sanitizer?: SanitizerFn|null): typeof ɵɵhostProperty {
|
||||
const lView = getLView();
|
||||
const bindingIndex = nextBindingIndex();
|
||||
if (bindingUpdated(lView, bindingIndex, value)) {
|
||||
@ -63,8 +63,8 @@ export function ɵɵhostProperty<T>(
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵupdateSyntheticHostBinding<T>(
|
||||
propName: string, value: T | NO_CHANGE,
|
||||
sanitizer?: SanitizerFn | null): typeof ɵɵupdateSyntheticHostBinding {
|
||||
propName: string, value: T|NO_CHANGE,
|
||||
sanitizer?: SanitizerFn|null): typeof ɵɵupdateSyntheticHostBinding {
|
||||
const lView = getLView();
|
||||
const bindingIndex = nextBindingIndex();
|
||||
if (bindingUpdated(lView, bindingIndex, value)) {
|
||||
|
@ -102,10 +102,9 @@ export function interpolation4(
|
||||
const different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
incrementBindingIndex(4);
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + suffix :
|
||||
NO_CHANGE;
|
||||
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
|
||||
renderStringify(v2) + i2 + renderStringify(v3) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,10 +118,9 @@ export function interpolation5(
|
||||
different = bindingUpdated(lView, bindingIndex + 4, v4) || different;
|
||||
incrementBindingIndex(5);
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + suffix :
|
||||
NO_CHANGE;
|
||||
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
|
||||
renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,11 +152,10 @@ export function interpolation7(
|
||||
different = bindingUpdated3(lView, bindingIndex + 4, v4, v5, v6) || different;
|
||||
incrementBindingIndex(7);
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + i5 +
|
||||
renderStringify(v6) + suffix :
|
||||
NO_CHANGE;
|
||||
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
|
||||
renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
|
||||
renderStringify(v5) + i5 + renderStringify(v6) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,9 +170,8 @@ export function interpolation8(
|
||||
different = bindingUpdated4(lView, bindingIndex + 4, v4, v5, v6, v7) || different;
|
||||
incrementBindingIndex(8);
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + i5 +
|
||||
renderStringify(v6) + i6 + renderStringify(v7) + suffix :
|
||||
NO_CHANGE;
|
||||
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
|
||||
renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
|
||||
renderStringify(v5) + i5 + renderStringify(v6) + i6 + renderStringify(v7) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
@ -11,12 +11,13 @@ import {assertDataInRange} from '../../util/assert';
|
||||
import {isObservable} from '../../util/lang';
|
||||
import {EMPTY_OBJ} from '../empty';
|
||||
import {PropertyAliasValue, TNode, TNodeFlags, TNodeType} from '../interfaces/node';
|
||||
import {GlobalTargetResolver, RElement, Renderer3, isProceduralRenderer} from '../interfaces/renderer';
|
||||
import {GlobalTargetResolver, isProceduralRenderer, RElement, Renderer3} from '../interfaces/renderer';
|
||||
import {isDirectiveHost} from '../interfaces/type_checks';
|
||||
import {CLEANUP, FLAGS, LView, LViewFlags, RENDERER, TView} from '../interfaces/view';
|
||||
import {assertNodeOfPossibleTypes} from '../node_assert';
|
||||
import {getLView, getPreviousOrParentTNode, getTView} from '../state';
|
||||
import {getComponentLViewByIndex, getNativeByTNode, unwrapRNode} from '../util/view_utils';
|
||||
|
||||
import {getLCleanup, handleError, loadComponentRenderer, markViewDirty} from './shared';
|
||||
|
||||
|
||||
@ -47,26 +48,26 @@ export function ɵɵlistener(
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a synthetic host listener (e.g. `(@foo.start)`) on a component.
|
||||
*
|
||||
* This instruction is for compatibility purposes and is designed to ensure that a
|
||||
* synthetic host listener (e.g. `@HostListener('@foo.start')`) properly gets rendered
|
||||
* in the component's renderer. Normally all host listeners are evaluated with the
|
||||
* parent component's renderer, but, in the case of animation @triggers, they need
|
||||
* to be evaluated with the sub component's renderer (because that's where the
|
||||
* animation triggers are defined).
|
||||
*
|
||||
* Do not use this instruction as a replacement for `listener`. This instruction
|
||||
* only exists to ensure compatibility with the ViewEngine's host binding behavior.
|
||||
*
|
||||
* @param eventName Name of the event
|
||||
* @param listenerFn The function to be called when event emits
|
||||
* @param useCapture Whether or not to use capture in event listener
|
||||
* @param eventTargetResolver Function that returns global target information in case this listener
|
||||
* should be attached to a global object like window, document or body
|
||||
* Registers a synthetic host listener (e.g. `(@foo.start)`) on a component.
|
||||
*
|
||||
* This instruction is for compatibility purposes and is designed to ensure that a
|
||||
* synthetic host listener (e.g. `@HostListener('@foo.start')`) properly gets rendered
|
||||
* in the component's renderer. Normally all host listeners are evaluated with the
|
||||
* parent component's renderer, but, in the case of animation @triggers, they need
|
||||
* to be evaluated with the sub component's renderer (because that's where the
|
||||
* animation triggers are defined).
|
||||
*
|
||||
* Do not use this instruction as a replacement for `listener`. This instruction
|
||||
* only exists to ensure compatibility with the ViewEngine's host binding behavior.
|
||||
*
|
||||
* @param eventName Name of the event
|
||||
* @param listenerFn The function to be called when event emits
|
||||
* @param useCapture Whether or not to use capture in event listener
|
||||
* @param eventTargetResolver Function that returns global target information in case this listener
|
||||
* should be attached to a global object like window, document or body
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
*/
|
||||
export function ɵɵcomponentHostSyntheticListener(
|
||||
eventName: string, listenerFn: (e?: any) => any, useCapture = false,
|
||||
eventTargetResolver?: GlobalTargetResolver): typeof ɵɵcomponentHostSyntheticListener {
|
||||
@ -94,7 +95,7 @@ function findExistingListener(
|
||||
// We have found a matching event name on the same node but it might not have been
|
||||
// registered yet, so we must explicitly verify entries in the LView cleanup data
|
||||
// structures.
|
||||
const lCleanup = lView[CLEANUP] !;
|
||||
const lCleanup = lView[CLEANUP]!;
|
||||
const listenerIdxInLCleanup = tCleanup[i + 2];
|
||||
return lCleanup.length > listenerIdxInLCleanup ? lCleanup[listenerIdxInLCleanup] : null;
|
||||
}
|
||||
@ -124,8 +125,9 @@ function listenerInternal(
|
||||
// register a listener and store its cleanup function on LView.
|
||||
const lCleanup = getLCleanup(lView);
|
||||
|
||||
ngDevMode && assertNodeOfPossibleTypes(
|
||||
tNode, TNodeType.Element, TNodeType.Container, TNodeType.ElementContainer);
|
||||
ngDevMode &&
|
||||
assertNodeOfPossibleTypes(
|
||||
tNode, TNodeType.Element, TNodeType.Container, TNodeType.ElementContainer);
|
||||
|
||||
let processOutputs = true;
|
||||
|
||||
@ -207,8 +209,8 @@ function listenerInternal(
|
||||
const output = directiveInstance[minifiedName];
|
||||
|
||||
if (ngDevMode && !isObservable(output)) {
|
||||
throw new Error(
|
||||
`@Output ${minifiedName} not initialized in '${directiveInstance.constructor.name}'.`);
|
||||
throw new Error(`@Output ${minifiedName} not initialized in '${
|
||||
directiveInstance.constructor.name}'.`);
|
||||
}
|
||||
|
||||
const subscription = output.subscribe(listenerFn);
|
||||
|
@ -79,9 +79,9 @@ export function ɵɵprojectionDef(projectionSlots?: ProjectionSlots): void {
|
||||
// If no explicit projection slots are defined, fall back to a single
|
||||
// projection slot with the wildcard selector.
|
||||
const numProjectionSlots = projectionSlots ? projectionSlots.length : 1;
|
||||
const projectionHeads: (TNode | null)[] = componentNode.projection =
|
||||
newArray(numProjectionSlots, null !as TNode);
|
||||
const tails: (TNode | null)[] = projectionHeads.slice();
|
||||
const projectionHeads: (TNode|null)[] = componentNode.projection =
|
||||
newArray(numProjectionSlots, null! as TNode);
|
||||
const tails: (TNode|null)[] = projectionHeads.slice();
|
||||
|
||||
let componentChild: TNode|null = componentNode.child;
|
||||
|
||||
@ -91,7 +91,7 @@ export function ɵɵprojectionDef(projectionSlots?: ProjectionSlots): void {
|
||||
|
||||
if (slotIndex !== null) {
|
||||
if (tails[slotIndex]) {
|
||||
tails[slotIndex] !.projectionNext = componentChild;
|
||||
tails[slotIndex]!.projectionNext = componentChild;
|
||||
} else {
|
||||
projectionHeads[slotIndex] = componentChild;
|
||||
}
|
||||
@ -119,7 +119,7 @@ export function setDelayProjection(value: boolean) {
|
||||
* - 1 based index of the selector from the {@link projectionDef}
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
*/
|
||||
export function ɵɵprojection(
|
||||
nodeIndex: number, selectorIndex: number = 0, attrs?: TAttributes): void {
|
||||
const lView = getLView();
|
||||
|
@ -33,7 +33,7 @@ import {elementPropertyInternal, setInputsForProperty, storePropertyBindingMetad
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵproperty<T>(
|
||||
propName: string, value: T, sanitizer?: SanitizerFn | null): typeof ɵɵproperty {
|
||||
propName: string, value: T, sanitizer?: SanitizerFn|null): typeof ɵɵproperty {
|
||||
const lView = getLView();
|
||||
const bindingIndex = nextBindingIndex();
|
||||
if (bindingUpdated(lView, bindingIndex, value)) {
|
||||
@ -52,7 +52,7 @@ export function ɵɵproperty<T>(
|
||||
*/
|
||||
export function setDirectiveInputsWhichShadowsStyling(
|
||||
tView: TView, tNode: TNode, lView: LView, value: any, isClassBased: boolean) {
|
||||
const inputs = tNode.inputs !;
|
||||
const inputs = tNode.inputs!;
|
||||
const property = isClassBased ? 'class' : 'style';
|
||||
// We support both 'class' and `className` hence the fallback.
|
||||
setInputsForProperty(tView, lView, inputs[property], property, value);
|
||||
|
@ -88,8 +88,9 @@ export function ɵɵpropertyInterpolate1(
|
||||
const tNode = getSelectedTNode();
|
||||
elementPropertyInternal(
|
||||
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 1, prefix, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 1, prefix, suffix);
|
||||
}
|
||||
return ɵɵpropertyInterpolate1;
|
||||
}
|
||||
@ -134,8 +135,9 @@ export function ɵɵpropertyInterpolate2(
|
||||
const tNode = getSelectedTNode();
|
||||
elementPropertyInternal(
|
||||
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 2, prefix, i0, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 2, prefix, i0, suffix);
|
||||
}
|
||||
return ɵɵpropertyInterpolate2;
|
||||
}
|
||||
@ -183,8 +185,9 @@ export function ɵɵpropertyInterpolate3(
|
||||
const tNode = getSelectedTNode();
|
||||
elementPropertyInternal(
|
||||
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 3, prefix, i0, i1, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 3, prefix, i0, i1, suffix);
|
||||
}
|
||||
return ɵɵpropertyInterpolate3;
|
||||
}
|
||||
@ -408,9 +411,10 @@ export function ɵɵpropertyInterpolate7(
|
||||
const tNode = getSelectedTNode();
|
||||
elementPropertyInternal(
|
||||
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 7, prefix, i0, i1, i2, i3, i4,
|
||||
i5, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 7, prefix, i0, i1, i2, i3, i4, i5,
|
||||
suffix);
|
||||
}
|
||||
return ɵɵpropertyInterpolate7;
|
||||
}
|
||||
@ -470,9 +474,10 @@ export function ɵɵpropertyInterpolate8(
|
||||
const tNode = getSelectedTNode();
|
||||
elementPropertyInternal(
|
||||
tView, tNode, lView, propName, interpolatedValue, lView[RENDERER], sanitizer, false);
|
||||
ngDevMode && storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 8, prefix, i0, i1, i2, i3, i4,
|
||||
i5, i6, suffix);
|
||||
ngDevMode &&
|
||||
storePropertyBindingMetadata(
|
||||
tView.data, tNode, propName, getBindingIndex() - 8, prefix, i0, i1, i2, i3, i4, i5, i6,
|
||||
suffix);
|
||||
}
|
||||
return ɵɵpropertyInterpolate8;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import {checkStylingProperty} from './styling';
|
||||
*/
|
||||
export function ɵɵstylePropInterpolate1(
|
||||
prop: string, prefix: string, v0: any, suffix: string,
|
||||
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate1 {
|
||||
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate1 {
|
||||
const lView = getLView();
|
||||
const interpolatedValue = interpolation1(lView, prefix, v0, suffix);
|
||||
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);
|
||||
@ -76,7 +76,7 @@ export function ɵɵstylePropInterpolate1(
|
||||
*/
|
||||
export function ɵɵstylePropInterpolate2(
|
||||
prop: string, prefix: string, v0: any, i0: string, v1: any, suffix: string,
|
||||
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate2 {
|
||||
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate2 {
|
||||
const lView = getLView();
|
||||
const interpolatedValue = interpolation2(lView, prefix, v0, i0, v1, suffix);
|
||||
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);
|
||||
@ -115,7 +115,7 @@ export function ɵɵstylePropInterpolate2(
|
||||
*/
|
||||
export function ɵɵstylePropInterpolate3(
|
||||
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, suffix: string,
|
||||
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate3 {
|
||||
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate3 {
|
||||
const lView = getLView();
|
||||
const interpolatedValue = interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix);
|
||||
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);
|
||||
@ -156,7 +156,7 @@ export function ɵɵstylePropInterpolate3(
|
||||
*/
|
||||
export function ɵɵstylePropInterpolate4(
|
||||
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
|
||||
v3: any, suffix: string, valueSuffix?: string | null): typeof ɵɵstylePropInterpolate4 {
|
||||
v3: any, suffix: string, valueSuffix?: string|null): typeof ɵɵstylePropInterpolate4 {
|
||||
const lView = getLView();
|
||||
const interpolatedValue = interpolation4(lView, prefix, v0, i0, v1, i1, v2, i2, v3, suffix);
|
||||
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);
|
||||
@ -200,7 +200,7 @@ export function ɵɵstylePropInterpolate4(
|
||||
export function ɵɵstylePropInterpolate5(
|
||||
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
|
||||
v3: any, i3: string, v4: any, suffix: string,
|
||||
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate5 {
|
||||
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate5 {
|
||||
const lView = getLView();
|
||||
const interpolatedValue =
|
||||
interpolation5(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix);
|
||||
@ -247,7 +247,7 @@ export function ɵɵstylePropInterpolate5(
|
||||
export function ɵɵstylePropInterpolate6(
|
||||
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
|
||||
v3: any, i3: string, v4: any, i4: string, v5: any, suffix: string,
|
||||
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate6 {
|
||||
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate6 {
|
||||
const lView = getLView();
|
||||
const interpolatedValue =
|
||||
interpolation6(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix);
|
||||
@ -297,7 +297,7 @@ export function ɵɵstylePropInterpolate6(
|
||||
export function ɵɵstylePropInterpolate7(
|
||||
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
|
||||
v3: any, i3: string, v4: any, i4: string, v5: any, i5: string, v6: any, suffix: string,
|
||||
valueSuffix?: string | null): typeof ɵɵstylePropInterpolate7 {
|
||||
valueSuffix?: string|null): typeof ɵɵstylePropInterpolate7 {
|
||||
const lView = getLView();
|
||||
const interpolatedValue =
|
||||
interpolation7(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix);
|
||||
@ -349,7 +349,7 @@ export function ɵɵstylePropInterpolate7(
|
||||
export function ɵɵstylePropInterpolate8(
|
||||
prop: string, prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string,
|
||||
v3: any, i3: string, v4: any, i4: string, v5: any, i5: string, v6: any, i6: string, v7: any,
|
||||
suffix: string, valueSuffix?: string | null): typeof ɵɵstylePropInterpolate8 {
|
||||
suffix: string, valueSuffix?: string|null): typeof ɵɵstylePropInterpolate8 {
|
||||
const lView = getLView();
|
||||
const interpolatedValue = interpolation8(
|
||||
lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix);
|
||||
@ -388,7 +388,7 @@ export function ɵɵstylePropInterpolate8(
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵstylePropInterpolateV(
|
||||
prop: string, values: any[], valueSuffix?: string | null): typeof ɵɵstylePropInterpolateV {
|
||||
prop: string, values: any[], valueSuffix?: string|null): typeof ɵɵstylePropInterpolateV {
|
||||
const lView = getLView();
|
||||
const interpolatedValue = interpolationV(lView, values);
|
||||
checkStylingProperty(prop, interpolatedValue, valueSuffix, false);
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {SafeValue, unwrapSafeValue} from '../../sanitization/bypass';
|
||||
import {stylePropNeedsSanitization, ɵɵsanitizeStyle} from '../../sanitization/sanitization';
|
||||
@ -19,7 +19,7 @@ import {DirectiveDef} from '../interfaces/definition';
|
||||
import {AttributeMarker, TAttributes, TNode, TNodeFlags, TNodeType} from '../interfaces/node';
|
||||
import {RElement, Renderer3} from '../interfaces/renderer';
|
||||
import {SanitizerFn} from '../interfaces/sanitization';
|
||||
import {TStylingKey, TStylingRange, getTStylingRangeNext, getTStylingRangeNextDuplicate, getTStylingRangePrev, getTStylingRangePrevDuplicate} from '../interfaces/styling';
|
||||
import {getTStylingRangeNext, getTStylingRangeNextDuplicate, getTStylingRangePrev, getTStylingRangePrevDuplicate, TStylingKey, TStylingRange} from '../interfaces/styling';
|
||||
import {HEADER_OFFSET, LView, RENDERER, TData, TView} from '../interfaces/view';
|
||||
import {applyStyling} from '../node_manipulation';
|
||||
import {getCurrentDirectiveIndex, getCurrentStyleSanitizer, getLView, getSelectedIndex, getTView, incrementBindingIndex, setCurrentStyleSanitizer} from '../state';
|
||||
@ -27,6 +27,7 @@ import {insertTStylingBinding} from '../styling/style_binding_list';
|
||||
import {getLastParsedKey, getLastParsedValue, parseClassName, parseClassNameNext, parseStyle, parseStyleNext} from '../styling/styling_parser';
|
||||
import {NO_CHANGE} from '../tokens';
|
||||
import {getNativeByIndex} from '../util/view_utils';
|
||||
|
||||
import {setDirectiveInputsWhichShadowsStyling} from './property';
|
||||
|
||||
|
||||
@ -46,7 +47,7 @@ import {setDirectiveInputsWhichShadowsStyling} from './property';
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn | null): void {
|
||||
export function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn|null): void {
|
||||
setCurrentStyleSanitizer(sanitizer);
|
||||
}
|
||||
|
||||
@ -72,8 +73,8 @@ export function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn | null): void {
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵstyleProp(
|
||||
prop: string, value: string | number | SafeValue | undefined | null,
|
||||
suffix?: string | null): typeof ɵɵstyleProp {
|
||||
prop: string, value: string|number|SafeValue|undefined|null,
|
||||
suffix?: string|null): typeof ɵɵstyleProp {
|
||||
checkStylingProperty(prop, value, suffix, false);
|
||||
return ɵɵstyleProp;
|
||||
}
|
||||
@ -93,8 +94,7 @@ export function ɵɵstyleProp(
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵclassProp(
|
||||
className: string, value: boolean | undefined | null): typeof ɵɵclassProp {
|
||||
export function ɵɵclassProp(className: string, value: boolean|undefined|null): typeof ɵɵclassProp {
|
||||
checkStylingProperty(className, value, null, true);
|
||||
return ɵɵclassProp;
|
||||
}
|
||||
@ -119,7 +119,7 @@ export function ɵɵclassProp(
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵstyleMap(styles: {[styleName: string]: any} | string | undefined | null): void {
|
||||
export function ɵɵstyleMap(styles: {[styleName: string]: any}|string|undefined|null): void {
|
||||
checkStylingMap(styleKeyValueArraySet, styleStringParser, styles, false);
|
||||
}
|
||||
|
||||
@ -158,8 +158,8 @@ export function styleStringParser(keyValueArray: KeyValueArray<any>, text: strin
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵclassMap(
|
||||
classes: {[className: string]: boolean | undefined | null} | string | undefined | null): void {
|
||||
export function ɵɵclassMap(classes: {[className: string]: boolean|undefined|null}|string|undefined|
|
||||
null): void {
|
||||
checkStylingMap(keyValueArraySet, classStringParser, classes, true);
|
||||
}
|
||||
|
||||
@ -187,8 +187,8 @@ export function classStringParser(keyValueArray: KeyValueArray<any>, text: strin
|
||||
* @param isClassBased `true` if `class` change (`false` if `style`)
|
||||
*/
|
||||
export function checkStylingProperty(
|
||||
prop: string, value: any | NO_CHANGE,
|
||||
suffixOrSanitizer: SanitizerFn | string | undefined | null, isClassBased: boolean): void {
|
||||
prop: string, value: any|NO_CHANGE, suffixOrSanitizer: SanitizerFn|string|undefined|null,
|
||||
isClassBased: boolean): void {
|
||||
const lView = getLView();
|
||||
const tView = getTView();
|
||||
// Styling instructions use 2 slots per binding.
|
||||
@ -289,14 +289,14 @@ function isInHostBindings(tView: TView, bindingIndex: number): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the necessary information to insert the binding into a linked list of style bindings
|
||||
* using `insertTStylingBinding`.
|
||||
*
|
||||
* @param tView `TView` where the binding linked list will be stored.
|
||||
* @param tStylingKey Property/key of the binding.
|
||||
* @param bindingIndex Index of binding associated with the `prop`
|
||||
* @param isClassBased `true` if `class` change (`false` if `style`)
|
||||
*/
|
||||
* Collects the necessary information to insert the binding into a linked list of style bindings
|
||||
* using `insertTStylingBinding`.
|
||||
*
|
||||
* @param tView `TView` where the binding linked list will be stored.
|
||||
* @param tStylingKey Property/key of the binding.
|
||||
* @param bindingIndex Index of binding associated with the `prop`
|
||||
* @param isClassBased `true` if `class` change (`false` if `style`)
|
||||
*/
|
||||
function stylingFirstUpdatePass(
|
||||
tView: TView, tStylingKey: TStylingKey, bindingIndex: number, isClassBased: boolean): void {
|
||||
ngDevMode && assertFirstUpdatePass(tView);
|
||||
@ -477,9 +477,10 @@ function getTemplateHeadTStylingKey(tData: TData, tNode: TNode, isClassBased: bo
|
||||
function setTemplateHeadTStylingKey(
|
||||
tData: TData, tNode: TNode, isClassBased: boolean, tStylingKey: TStylingKey): void {
|
||||
const bindings = isClassBased ? tNode.classBindings : tNode.styleBindings;
|
||||
ngDevMode && assertNotEqual(
|
||||
getTStylingRangeNext(bindings), 0,
|
||||
'Expecting to have at least one template styling binding.');
|
||||
ngDevMode &&
|
||||
assertNotEqual(
|
||||
getTStylingRangeNext(bindings), 0,
|
||||
'Expecting to have at least one template styling binding.');
|
||||
tData[getTStylingRangePrev(bindings)] = tStylingKey;
|
||||
}
|
||||
|
||||
@ -523,7 +524,7 @@ function collectResidual(tData: TData, tNode: TNode, isClassBased: boolean): Key
|
||||
* @param isClassBased `true` if `class` (`false` if `style`)
|
||||
*/
|
||||
function collectStylingFromDirectives(
|
||||
hostDirectiveDef: DirectiveDef<any>| null, tData: TData, tNode: TNode, stylingKey: TStylingKey,
|
||||
hostDirectiveDef: DirectiveDef<any>|null, tData: TData, tNode: TNode, stylingKey: TStylingKey,
|
||||
isClassBased: boolean): TStylingKey {
|
||||
// We need to loop because there can be directives which have `hostAttrs` but don't have
|
||||
// `hostBindings` so this loop catches up to the current directive..
|
||||
@ -559,7 +560,7 @@ function collectStylingFromDirectives(
|
||||
* @param isClassBased `true` if `class` (`false` if `style`)
|
||||
*/
|
||||
function collectStylingFromTAttrs(
|
||||
stylingKey: TStylingKey | undefined, attrs: TAttributes | null,
|
||||
stylingKey: TStylingKey|undefined, attrs: TAttributes|null,
|
||||
isClassBased: boolean): TStylingKey {
|
||||
const desiredMarker = isClassBased ? AttributeMarker.Classes : AttributeMarker.Styles;
|
||||
let currentMarker = AttributeMarker.ImplicitAttributes;
|
||||
@ -711,7 +712,7 @@ function updateStylingMap(
|
||||
setKey = newKey;
|
||||
setValue = newValue;
|
||||
}
|
||||
} else if (newKey === null || oldKey !== null && oldKey < newKey !) {
|
||||
} else if (newKey === null || oldKey !== null && oldKey < newKey!) {
|
||||
// DELETE: oldKey key is missing or we did not find the oldKey in the newValue
|
||||
// (because the keyValueArray is sorted and `newKey` is found later alphabetically).
|
||||
// `"background" < "color"` so we need to delete `"background"` because it is not found in the
|
||||
@ -754,7 +755,7 @@ function updateStylingMap(
|
||||
*/
|
||||
function updateStyling(
|
||||
tView: TView, tNode: TNode, lView: LView, renderer: Renderer3, prop: string,
|
||||
value: string | undefined | null | boolean, isClassBased: boolean, bindingIndex: number) {
|
||||
value: string|undefined|null|boolean, isClassBased: boolean, bindingIndex: number) {
|
||||
if (tNode.type !== TNodeType.Element) {
|
||||
// It is possible to have styling on non-elements (such as ng-container).
|
||||
// This is rare, but it does happen. In such a case, just ignore the binding.
|
||||
@ -811,7 +812,7 @@ function updateStyling(
|
||||
* @param isClassBased `true` if `class` (`false` if `style`)
|
||||
*/
|
||||
function findStylingValue(
|
||||
tData: TData, tNode: TNode | null, lView: LView, prop: string, index: number,
|
||||
tData: TData, tNode: TNode|null, lView: LView, prop: string, index: number,
|
||||
isClassBased: boolean): any {
|
||||
// `TNode` to use for resolving static styling. Also controls search direction.
|
||||
// - `TNode` search next and quit as soon as `isStylingValuePresent(value)` is true.
|
||||
@ -856,7 +857,7 @@ function findStylingValue(
|
||||
// consult residual styling
|
||||
let residual = isClassBased ? tNode.residualClasses : tNode.residualStyles;
|
||||
if (residual != null /** OR residual !=== undefined */) {
|
||||
value = keyValueArrayGet(residual !, prop);
|
||||
value = keyValueArrayGet(residual!, prop);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
@ -884,7 +885,7 @@ function isStylingValuePresent(value: any): boolean {
|
||||
* @param suffixOrSanitizer
|
||||
*/
|
||||
function normalizeAndApplySuffixOrSanitizer(
|
||||
value: any, suffixOrSanitizer: SanitizerFn | string | undefined | null): string|null|undefined|
|
||||
value: any, suffixOrSanitizer: SanitizerFn|string|undefined|null): string|null|undefined|
|
||||
boolean {
|
||||
if (value == null /** || value === undefined */) {
|
||||
// do nothing
|
||||
|
@ -27,9 +27,10 @@ export function ɵɵtext(index: number, value: string = ''): void {
|
||||
const tView = getTView();
|
||||
const adjustedIndex = index + HEADER_OFFSET;
|
||||
|
||||
ngDevMode && assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'text nodes should be created before any bindings');
|
||||
ngDevMode &&
|
||||
assertEqual(
|
||||
getBindingIndex(), tView.bindingStartIndex,
|
||||
'text nodes should be created before any bindings');
|
||||
ngDevMode && assertDataInRange(lView, adjustedIndex);
|
||||
|
||||
const tNode = tView.firstCreatePass ?
|
||||
|
@ -22,7 +22,7 @@ export type ComponentTemplate<T> = {
|
||||
// Note: the ctx parameter is typed as T|U, as using only U would prevent a template with
|
||||
// e.g. ctx: {} from being assigned to ComponentTemplate<any> as TypeScript won't infer U = any
|
||||
// in that scenario. By including T this incompatibility is resolved.
|
||||
<U extends T>(rf: RenderFlags, ctx: T | U): void;
|
||||
<U extends T>(rf: RenderFlags, ctx: T|U): void;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -72,7 +72,9 @@ export const enum RenderFlags {
|
||||
* A subclass of `Type` which has a static `ɵcmp`:`ComponentDef` field making it
|
||||
* consumable for rendering.
|
||||
*/
|
||||
export interface ComponentType<T> extends Type<T> { ɵcmp: never; }
|
||||
export interface ComponentType<T> extends Type<T> {
|
||||
ɵcmp: never;
|
||||
}
|
||||
|
||||
/**
|
||||
* A subclass of `Type` which has a static `ɵdir`:`DirectiveDef` field making it
|
||||
@ -87,7 +89,9 @@ export interface DirectiveType<T> extends Type<T> {
|
||||
* A subclass of `Type` which has a static `ɵpipe`:`PipeDef` field making it
|
||||
* consumable for rendering.
|
||||
*/
|
||||
export interface PipeType<T> extends Type<T> { ɵpipe: never; }
|
||||
export interface PipeType<T> extends Type<T> {
|
||||
ɵpipe: never;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object literal of this type is used to represent the metadata of a constructor dependency.
|
||||
@ -99,7 +103,7 @@ export type CtorDependency = {
|
||||
* attribute name is a dynamic expression instead of a string literal, this will be the unknown
|
||||
* type.
|
||||
*/
|
||||
attribute?: string | unknown;
|
||||
attribute?: string|unknown;
|
||||
|
||||
/**
|
||||
* If `@Optional()` is used, this key is set to true.
|
||||
@ -120,14 +124,17 @@ export type CtorDependency = {
|
||||
* If `@SkipSelf` is used, this key is set to true.
|
||||
*/
|
||||
skipSelf?: true;
|
||||
} | null;
|
||||
}|null;
|
||||
|
||||
/**
|
||||
* @codeGenApi
|
||||
*/
|
||||
export type ɵɵDirectiveDefWithMeta<
|
||||
T, Selector extends string, ExportAs extends string[], InputMap extends{[key: string]: string},
|
||||
OutputMap extends{[key: string]: string}, QueryFields extends string[]> = DirectiveDef<T>;
|
||||
T, Selector extends string, ExportAs extends
|
||||
string[], InputMap extends {[key: string]: string},
|
||||
OutputMap extends {[key: string]: string},
|
||||
QueryFields extends string[]> =
|
||||
DirectiveDef<T>;
|
||||
|
||||
/**
|
||||
* Runtime link information for Directives.
|
||||
@ -268,9 +275,10 @@ export interface DirectiveDef<T> {
|
||||
* @codeGenApi
|
||||
*/
|
||||
export type ɵɵComponentDefWithMeta<
|
||||
T, Selector extends String, ExportAs extends string[], InputMap extends{[key: string]: string},
|
||||
OutputMap extends{[key: string]: string}, QueryFields extends string[],
|
||||
NgContentSelectors extends string[]> = ComponentDef<T>;
|
||||
T, Selector extends String, ExportAs extends
|
||||
string[], InputMap extends {[key: string]: string},
|
||||
OutputMap extends {[key: string]: string}, QueryFields extends
|
||||
string[], NgContentSelectors extends string[]> = ComponentDef<T>;
|
||||
|
||||
/**
|
||||
* @codeGenApi
|
||||
@ -467,14 +475,14 @@ export interface ComponentDefFeature {
|
||||
*
|
||||
* The function is necessary to be able to support forward declarations.
|
||||
*/
|
||||
export type DirectiveDefListOrFactory = (() => DirectiveDefList) | DirectiveDefList;
|
||||
export type DirectiveDefListOrFactory = (() => DirectiveDefList)|DirectiveDefList;
|
||||
|
||||
export type DirectiveDefList = (DirectiveDef<any>| ComponentDef<any>)[];
|
||||
export type DirectiveDefList = (DirectiveDef<any>|ComponentDef<any>)[];
|
||||
|
||||
export type DirectiveTypesOrFactory = (() => DirectiveTypeList) | DirectiveTypeList;
|
||||
export type DirectiveTypesOrFactory = (() => DirectiveTypeList)|DirectiveTypeList;
|
||||
|
||||
export type DirectiveTypeList =
|
||||
(DirectiveType<any>| ComponentType<any>|
|
||||
(DirectiveType<any>|ComponentType<any>|
|
||||
Type<any>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[];
|
||||
|
||||
export type HostBindingsFunction<T> = <U extends T>(rf: RenderFlags, ctx: U) => void;
|
||||
@ -484,14 +492,14 @@ export type HostBindingsFunction<T> = <U extends T>(rf: RenderFlags, ctx: U) =>
|
||||
*
|
||||
* The function is necessary to be able to support forward declarations.
|
||||
*/
|
||||
export type PipeDefListOrFactory = (() => PipeDefList) | PipeDefList;
|
||||
export type PipeDefListOrFactory = (() => PipeDefList)|PipeDefList;
|
||||
|
||||
export type PipeDefList = PipeDef<any>[];
|
||||
|
||||
export type PipeTypesOrFactory = (() => PipeTypeList) | PipeTypeList;
|
||||
export type PipeTypesOrFactory = (() => PipeTypeList)|PipeTypeList;
|
||||
|
||||
export type PipeTypeList =
|
||||
(PipeType<any>| Type<any>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[];
|
||||
(PipeType<any>|Type<any>/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[];
|
||||
|
||||
|
||||
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
||||
|
@ -31,7 +31,7 @@ let DOCUMENT: Document|undefined = undefined;
|
||||
*
|
||||
* @param document The object representing the global `document` in this environment.
|
||||
*/
|
||||
export function setDocument(document: Document | undefined): void {
|
||||
export function setDocument(document: Document|undefined): void {
|
||||
DOCUMENT = document;
|
||||
}
|
||||
|
||||
@ -52,5 +52,5 @@ export function getDocument(): Document {
|
||||
// this should not happen in Angular apps.
|
||||
// Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
|
||||
// public API. Meanwhile we just return `undefined` and let the application fail.
|
||||
return undefined !;
|
||||
return undefined!;
|
||||
}
|
||||
|
@ -66,7 +66,9 @@ export const enum I18nMutateOpCode {
|
||||
export const ELEMENT_MARKER: ELEMENT_MARKER = {
|
||||
marker: 'element'
|
||||
};
|
||||
export interface ELEMENT_MARKER { marker: 'element'; }
|
||||
export interface ELEMENT_MARKER {
|
||||
marker: 'element';
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks that the next string is for comment.
|
||||
@ -77,7 +79,9 @@ export const COMMENT_MARKER: COMMENT_MARKER = {
|
||||
marker: 'comment'
|
||||
};
|
||||
|
||||
export interface COMMENT_MARKER { marker: 'comment'; }
|
||||
export interface COMMENT_MARKER {
|
||||
marker: 'comment';
|
||||
}
|
||||
|
||||
/**
|
||||
* Array storing OpCode for dynamically creating `i18n` blocks.
|
||||
|
@ -23,7 +23,9 @@ export const INJECTOR_BLOOM_PARENT_SIZE = 9;
|
||||
* The interfaces encodes number of parents `LView`s to traverse and index in the `LView`
|
||||
* pointing to the parent injector.
|
||||
*/
|
||||
export interface RelativeInjectorLocation { __brand__: 'RelativeInjectorLocationFlags'; }
|
||||
export interface RelativeInjectorLocation {
|
||||
__brand__: 'RelativeInjectorLocationFlags';
|
||||
}
|
||||
|
||||
export const enum RelativeInjectorLocationFlags {
|
||||
InjectorIndexMask = 0b111111111111111,
|
||||
@ -114,20 +116,20 @@ export const NO_PARENT_INJECTOR: RelativeInjectorLocation = -1 as any;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Factory for creating instances of injectors in the NodeInjector.
|
||||
*
|
||||
* This factory is complicated by the fact that it can resolve `multi` factories as well.
|
||||
*
|
||||
* NOTE: Some of the fields are optional which means that this class has two hidden classes.
|
||||
* - One without `multi` support (most common)
|
||||
* - One with `multi` values, (rare).
|
||||
*
|
||||
* Since VMs can cache up to 4 inline hidden classes this is OK.
|
||||
*
|
||||
* - Single factory: Only `resolving` and `factory` is defined.
|
||||
* - `providers` factory: `componentProviders` is a number and `index = -1`.
|
||||
* - `viewProviders` factory: `componentProviders` is a number and `index` points to `providers`.
|
||||
*/
|
||||
* Factory for creating instances of injectors in the NodeInjector.
|
||||
*
|
||||
* This factory is complicated by the fact that it can resolve `multi` factories as well.
|
||||
*
|
||||
* NOTE: Some of the fields are optional which means that this class has two hidden classes.
|
||||
* - One without `multi` support (most common)
|
||||
* - One with `multi` values, (rare).
|
||||
*
|
||||
* Since VMs can cache up to 4 inline hidden classes this is OK.
|
||||
*
|
||||
* - Single factory: Only `resolving` and `factory` is defined.
|
||||
* - `providers` factory: `componentProviders` is a number and `index = -1`.
|
||||
* - `viewProviders` factory: `componentProviders` is a number and `index` points to `providers`.
|
||||
*/
|
||||
export class NodeInjectorFactory {
|
||||
/**
|
||||
* The inject implementation to be activated when using the factory.
|
||||
@ -234,7 +236,8 @@ export class NodeInjectorFactory {
|
||||
/**
|
||||
* Set to `true` if the token is declared in `viewProviders` (or if it is component).
|
||||
*/
|
||||
isViewProvider: boolean, injectImplementation: null|
|
||||
isViewProvider: boolean,
|
||||
injectImplementation: null|
|
||||
(<T>(token: Type<T>|InjectionToken<T>, flags?: InjectFlags) => T)) {
|
||||
this.canSeeViewProviders = isViewProvider;
|
||||
this.injectImpl = injectImplementation;
|
||||
|
@ -90,8 +90,10 @@ export const enum TNodeProviderIndexes {
|
||||
/** The index of the first provider on this node is encoded on the least significant bits */
|
||||
ProvidersStartIndexMask = 0b00000000000000001111111111111111,
|
||||
|
||||
/** The count of view providers from the component on this node is encoded on the 16 most
|
||||
significant bits */
|
||||
/**
|
||||
The count of view providers from the component on this node is encoded on the 16 most
|
||||
significant bits
|
||||
*/
|
||||
CptViewProvidersCountShift = 16,
|
||||
CptViewProvidersCountShifter = 0b00000000000000010000000000000000,
|
||||
}
|
||||
@ -117,21 +119,21 @@ export const enum AttributeMarker {
|
||||
NamespaceURI = 0,
|
||||
|
||||
/**
|
||||
* Signals class declaration.
|
||||
*
|
||||
* Each value following `Classes` designates a class name to include on the element.
|
||||
* ## Example:
|
||||
*
|
||||
* Given:
|
||||
* ```
|
||||
* <div class="foo bar baz">...<d/vi>
|
||||
* ```
|
||||
*
|
||||
* the generated code is:
|
||||
* ```
|
||||
* var _c1 = [AttributeMarker.Classes, 'foo', 'bar', 'baz'];
|
||||
* ```
|
||||
*/
|
||||
* Signals class declaration.
|
||||
*
|
||||
* Each value following `Classes` designates a class name to include on the element.
|
||||
* ## Example:
|
||||
*
|
||||
* Given:
|
||||
* ```
|
||||
* <div class="foo bar baz">...<d/vi>
|
||||
* ```
|
||||
*
|
||||
* the generated code is:
|
||||
* ```
|
||||
* var _c1 = [AttributeMarker.Classes, 'foo', 'bar', 'baz'];
|
||||
* ```
|
||||
*/
|
||||
Classes = 1,
|
||||
|
||||
/**
|
||||
@ -235,14 +237,14 @@ export const enum AttributeMarker {
|
||||
* - Special markers acting as flags to alter attributes processing.
|
||||
* - Parsed ngProjectAs selectors.
|
||||
*/
|
||||
export type TAttributes = (string | AttributeMarker | CssSelector)[];
|
||||
export type TAttributes = (string|AttributeMarker|CssSelector)[];
|
||||
|
||||
/**
|
||||
* Constants that are associated with a view. Includes:
|
||||
* - Attribute arrays.
|
||||
* - Local definition arrays.
|
||||
*/
|
||||
export type TConstants = (TAttributes | string)[];
|
||||
export type TConstants = (TAttributes|string)[];
|
||||
|
||||
/**
|
||||
* Binding data (flyweight) for a particular node that is shared between all templates
|
||||
@ -700,7 +702,7 @@ export interface TProjectionNode extends TNode {
|
||||
/**
|
||||
* A union type representing all TNode types that can host a directive.
|
||||
*/
|
||||
export type TDirectiveHostNode = TElementNode | TContainerNode | TElementContainerNode;
|
||||
export type TDirectiveHostNode = TElementNode|TContainerNode|TElementContainerNode;
|
||||
|
||||
/**
|
||||
* This mapping is necessary so we can set input properties and output listeners
|
||||
@ -725,7 +727,7 @@ export type PropertyAliases = {
|
||||
*
|
||||
* e.g. [0, 'change-minified']
|
||||
*/
|
||||
export type PropertyAliasValue = (number | string)[];
|
||||
export type PropertyAliasValue = (number|string)[];
|
||||
|
||||
/**
|
||||
* This array contains information about input properties that
|
||||
@ -745,7 +747,7 @@ export type PropertyAliasValue = (number | string)[];
|
||||
*
|
||||
* e.g. [null, ['role-min', 'minified-input', 'button']]
|
||||
*/
|
||||
export type InitialInputData = (InitialInputs | null)[];
|
||||
export type InitialInputData = (InitialInputs|null)[];
|
||||
|
||||
/**
|
||||
* Used by InitialInputData to store input properties
|
||||
@ -766,7 +768,7 @@ export const unusedValueExportToPlacateAjd = 1;
|
||||
/**
|
||||
* Type representing a set of TNodes that can have local refs (`#foo`) placed on them.
|
||||
*/
|
||||
export type TNodeWithLocalRefs = TContainerNode | TElementNode | TElementContainerNode;
|
||||
export type TNodeWithLocalRefs = TContainerNode|TElementNode|TElementContainerNode;
|
||||
|
||||
/**
|
||||
* Type for a function that extracts a value for a local refs.
|
||||
|
@ -25,7 +25,9 @@ export const enum BindingType {
|
||||
Style = 2,
|
||||
}
|
||||
|
||||
export interface BindingStore { setValue(prop: string, value: any): void; }
|
||||
export interface BindingStore {
|
||||
setValue(prop: string, value: any): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the shape which produces the Player.
|
||||
@ -50,7 +52,9 @@ export interface PlayerFactoryBuildFn {
|
||||
* `[style]`, `[style.prop]`, `[class]` and `[class.name]` template bindings
|
||||
* all accept a `PlayerFactory` as input and this player factories.
|
||||
*/
|
||||
export interface PlayerFactory { '__brand__': 'Brand for PlayerFactory that nothing will match'; }
|
||||
export interface PlayerFactory {
|
||||
'__brand__': 'Brand for PlayerFactory that nothing will match';
|
||||
}
|
||||
|
||||
export interface PlayerBuilder extends BindingStore {
|
||||
buildPlayer(currentPlayer: Player|null, isFirstRender: boolean): Player|undefined|null;
|
||||
@ -63,7 +67,13 @@ export interface PlayerBuilder extends BindingStore {
|
||||
* code may compare state by checking if a number is higher or lower than
|
||||
* a certain numeric value.
|
||||
*/
|
||||
export const enum PlayState {Pending = 0, Running = 1, Paused = 2, Finished = 100, Destroyed = 200}
|
||||
export const enum PlayState {
|
||||
Pending = 0,
|
||||
Running = 1,
|
||||
Paused = 2,
|
||||
Finished = 100,
|
||||
Destroyed = 200
|
||||
}
|
||||
|
||||
/**
|
||||
* The context that stores all the active players and queued player factories present on an element.
|
||||
|
@ -37,7 +37,7 @@
|
||||
*
|
||||
* See more examples in node_selector_matcher_spec.ts
|
||||
*/
|
||||
export type CssSelector = (string | SelectorFlags)[];
|
||||
export type CssSelector = (string|SelectorFlags)[];
|
||||
|
||||
/**
|
||||
* A list of CssSelectors.
|
||||
@ -58,7 +58,7 @@ export type CssSelectorList = CssSelector[];
|
||||
* using {@link ViewContainerRef#createComponent}. The last slot that specifies the
|
||||
* wildcard selector will retrieve all projectable nodes which do not match any selector.
|
||||
*/
|
||||
export type ProjectionSlots = (CssSelectorList | '*')[];
|
||||
export type ProjectionSlots = (CssSelectorList|'*')[];
|
||||
|
||||
/** Flags used to build up CssSelectors */
|
||||
export const enum SelectorFlags {
|
||||
|
@ -145,7 +145,7 @@ export interface TQueries {
|
||||
template(tView: TView, tNode: TNode): void;
|
||||
|
||||
/**
|
||||
* A proxy method that iterates over all the TQueries in a given TView and calls the corresponding
|
||||
* A proxy method that iterates over all the TQueries in a given TView and calls the corresponding
|
||||
* `embeddedTView` on each and every TQuery.
|
||||
* @param tNode
|
||||
*/
|
||||
|
@ -24,9 +24,9 @@ export enum RendererStyleFlags3 {
|
||||
DashCase = 1 << 1
|
||||
}
|
||||
|
||||
export type Renderer3 = ObjectOrientedRenderer3 | ProceduralRenderer3;
|
||||
export type Renderer3 = ObjectOrientedRenderer3|ProceduralRenderer3;
|
||||
|
||||
export type GlobalTargetName = 'document' | 'window' | 'body';
|
||||
export type GlobalTargetName = 'document'|'window'|'body';
|
||||
|
||||
export type GlobalTargetResolver = (element: any) => {
|
||||
name: GlobalTargetName, target: EventTarget
|
||||
@ -49,8 +49,8 @@ export interface ObjectOrientedRenderer3 {
|
||||
}
|
||||
|
||||
/** Returns whether the `renderer` is a `ProceduralRenderer3` */
|
||||
export function isProceduralRenderer(renderer: ProceduralRenderer3 | ObjectOrientedRenderer3):
|
||||
renderer is ProceduralRenderer3 {
|
||||
export function isProceduralRenderer(renderer: ProceduralRenderer3|
|
||||
ObjectOrientedRenderer3): renderer is ProceduralRenderer3 {
|
||||
return !!((renderer as any).listen);
|
||||
}
|
||||
|
||||
@ -104,8 +104,9 @@ export interface RendererFactory3 {
|
||||
}
|
||||
|
||||
export const domRendererFactory3: RendererFactory3 = {
|
||||
createRenderer: (hostElement: RElement | null, rendererType: RendererType2 | null):
|
||||
Renderer3 => { return getDocument();}
|
||||
createRenderer: (hostElement: RElement|null, rendererType: RendererType2|null): Renderer3 => {
|
||||
return getDocument();
|
||||
}
|
||||
};
|
||||
|
||||
/** Subset of API needed for appending elements and text nodes. */
|
||||
@ -175,9 +176,13 @@ export interface RDomTokenList {
|
||||
remove(token: string): void;
|
||||
}
|
||||
|
||||
export interface RText extends RNode { textContent: string|null; }
|
||||
export interface RText extends RNode {
|
||||
textContent: string|null;
|
||||
}
|
||||
|
||||
export interface RComment extends RNode { textContent: string|null; }
|
||||
export interface RComment extends RNode {
|
||||
textContent: string|null;
|
||||
}
|
||||
|
||||
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
||||
// failure based on types.
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {KeyValueArray} from '../../util/array_utils';
|
||||
import {assertNumber, assertNumberInRange} from '../../util/assert';
|
||||
@ -14,7 +14,7 @@ import {assertNumber, assertNumberInRange} from '../../util/assert';
|
||||
*
|
||||
* See: `TStylingKeyPrimitive` and `TStylingStatic`
|
||||
*/
|
||||
export type TStylingKey = TStylingKeyPrimitive | TStylingStatic;
|
||||
export type TStylingKey = TStylingKeyPrimitive|TStylingStatic;
|
||||
|
||||
|
||||
/**
|
||||
@ -27,7 +27,7 @@ export type TStylingKey = TStylingKeyPrimitive | TStylingStatic;
|
||||
* is combined with directive which shadows its input `@Input('class')`. That way the binding
|
||||
* should not participate in the styling resolution.
|
||||
*/
|
||||
export type TStylingKeyPrimitive = string | null | false;
|
||||
export type TStylingKeyPrimitive = string|null|false;
|
||||
|
||||
/**
|
||||
* Store the static values for the styling binding.
|
||||
@ -119,7 +119,9 @@ export interface TStylingStatic extends KeyValueArray<any> {}
|
||||
*
|
||||
* NOTE: `0` has special significance and represents `null` as in no additional pointer.
|
||||
*/
|
||||
export interface TStylingRange { __brand__: 'TStylingRange'; }
|
||||
export interface TStylingRange {
|
||||
__brand__: 'TStylingRange';
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift and masks constants for encoding two numbers into and duplicate info into a single number.
|
||||
@ -177,9 +179,8 @@ export function setTStylingRangePrev(
|
||||
tStylingRange: TStylingRange, previous: number): TStylingRange {
|
||||
ngDevMode && assertNumber(tStylingRange, 'expected number');
|
||||
ngDevMode && assertNumberInRange(previous, 0, StylingRange.UNSIGNED_MASK);
|
||||
return (
|
||||
((tStylingRange as any as number) & ~StylingRange.PREV_MASK) |
|
||||
(previous << StylingRange.PREV_SHIFT)) as any;
|
||||
return (((tStylingRange as any as number) & ~StylingRange.PREV_MASK) |
|
||||
(previous << StylingRange.PREV_SHIFT)) as any;
|
||||
}
|
||||
|
||||
export function setTStylingRangePrevDuplicate(tStylingRange: TStylingRange): TStylingRange {
|
||||
@ -195,9 +196,8 @@ export function getTStylingRangeNext(tStylingRange: TStylingRange): number {
|
||||
export function setTStylingRangeNext(tStylingRange: TStylingRange, next: number): TStylingRange {
|
||||
ngDevMode && assertNumber(tStylingRange, 'expected number');
|
||||
ngDevMode && assertNumberInRange(next, 0, StylingRange.UNSIGNED_MASK);
|
||||
return (
|
||||
((tStylingRange as any as number) & ~StylingRange.NEXT_MASK) | //
|
||||
next << StylingRange.NEXT_SHIFT) as any;
|
||||
return (((tStylingRange as any as number) & ~StylingRange.NEXT_MASK) | //
|
||||
next << StylingRange.NEXT_SHIFT) as any;
|
||||
}
|
||||
|
||||
export function getTStylingRangeNextDuplicate(tStylingRange: TStylingRange): boolean {
|
||||
|
@ -15,10 +15,10 @@ import {FLAGS, LView, LViewFlags} from './view';
|
||||
|
||||
|
||||
/**
|
||||
* True if `value` is `LView`.
|
||||
* @param value wrapped value of `RNode`, `LView`, `LContainer`
|
||||
*/
|
||||
export function isLView(value: RNode | LView | LContainer | {} | null): value is LView {
|
||||
* True if `value` is `LView`.
|
||||
* @param value wrapped value of `RNode`, `LView`, `LContainer`
|
||||
*/
|
||||
export function isLView(value: RNode|LView|LContainer|{}|null): value is LView {
|
||||
return Array.isArray(value) && typeof value[TYPE] === 'object';
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ export function isLView(value: RNode | LView | LContainer | {} | null): value is
|
||||
* True if `value` is `LContainer`.
|
||||
* @param value wrapped value of `RNode`, `LView`, `LContainer`
|
||||
*/
|
||||
export function isLContainer(value: RNode | LView | LContainer | {} | null): value is LContainer {
|
||||
export function isLContainer(value: RNode|LView|LContainer|{}|null): value is LContainer {
|
||||
return Array.isArray(value) && value[TYPE] === true;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {R3DirectiveMetadataFacade, getCompilerFacade} from '../../compiler/compiler_facade';
|
||||
import {getCompilerFacade, R3DirectiveMetadataFacade} from '../../compiler/compiler_facade';
|
||||
import {R3ComponentMetadataFacade, R3QueryMetadataFacade} from '../../compiler/compiler_facade_interface';
|
||||
import {resolveForwardRef} from '../../di/forward_ref';
|
||||
import {getReflect, reflectDependencies} from '../../di/jit/util';
|
||||
@ -95,12 +95,14 @@ export function compileComponent(type: Type<any>, metadata: Component): void {
|
||||
const meta: R3ComponentMetadataFacade = {
|
||||
...directiveMetadata(type, metadata),
|
||||
typeSourceSpan: compiler.createParseSourceSpan('Component', type.name, templateUrl),
|
||||
template: metadata.template || '', preserveWhitespaces,
|
||||
template: metadata.template || '',
|
||||
preserveWhitespaces,
|
||||
styles: metadata.styles || EMPTY_ARRAY,
|
||||
animations: metadata.animations,
|
||||
directives: [],
|
||||
changeDetection: metadata.changeDetection,
|
||||
pipes: new Map(), encapsulation,
|
||||
pipes: new Map(),
|
||||
encapsulation,
|
||||
interpolation: metadata.interpolation,
|
||||
viewProviders: metadata.viewProviders || null,
|
||||
};
|
||||
@ -135,7 +137,7 @@ export function compileComponent(type: Type<any>, metadata: Component): void {
|
||||
|
||||
function hasSelectorScope<T>(component: Type<T>): component is Type<T>&
|
||||
{ngSelectorScope: Type<any>} {
|
||||
return (component as{ngSelectorScope?: any}).ngSelectorScope !== undefined;
|
||||
return (component as {ngSelectorScope?: any}).ngSelectorScope !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,7 +147,7 @@ function hasSelectorScope<T>(component: Type<T>): component is Type<T>&
|
||||
* In the event that compilation is not immediate, `compileDirective` will return a `Promise` which
|
||||
* will resolve when compilation completes and the directive becomes usable.
|
||||
*/
|
||||
export function compileDirective(type: Type<any>, directive: Directive | null): void {
|
||||
export function compileDirective(type: Type<any>, directive: Directive|null): void {
|
||||
let ngDirectiveDef: any = null;
|
||||
|
||||
addDirectiveFactoryDef(type, directive || {});
|
||||
@ -179,7 +181,7 @@ function getDirectiveMetadata(type: Type<any>, metadata: Directive) {
|
||||
return {metadata: facade, sourceMapUrl};
|
||||
}
|
||||
|
||||
function addDirectiveFactoryDef(type: Type<any>, metadata: Directive | Component) {
|
||||
function addDirectiveFactoryDef(type: Type<any>, metadata: Directive|Component) {
|
||||
let ngFactoryDef: any = null;
|
||||
|
||||
Object.defineProperty(type, NG_FACTORY_DEF, {
|
||||
@ -225,7 +227,7 @@ export function directiveMetadata(type: Type<any>, metadata: Directive): R3Direc
|
||||
outputs: metadata.outputs || EMPTY_ARRAY,
|
||||
queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
|
||||
lifecycle: {usesOnChanges: reflect.hasLifecycleHook(type, 'ngOnChanges')},
|
||||
typeSourceSpan: null !,
|
||||
typeSourceSpan: null!,
|
||||
usesInheritance: !extendsDirectlyFromObject(type),
|
||||
exportAs: extractExportAs(metadata.exportAs),
|
||||
providers: metadata.providers || null,
|
||||
@ -291,7 +293,7 @@ function extractQueriesMetadata(
|
||||
return queriesMeta;
|
||||
}
|
||||
|
||||
function extractExportAs(exportAs: string | undefined): string[]|null {
|
||||
function extractExportAs(exportAs: string|undefined): string[]|null {
|
||||
return exportAs === undefined ? null : splitByComma(exportAs);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user