chore(LifecycleEvent): change to PascalCase / rename
BREAKING CHANGE Closes #3863 - LifecycleEvent.onInit => LifecycleEvent.OnInit - LifecycleEvent.onDestroy => LifecycleEvent.OnDestroy - LifecycleEvent.onChange => LifecycleEvent.OnChanges - LifecycleEvent.onCheck => LifecycleEvent.DoCheck - LifecycleEvent.onAllChangesDone => LifecycleEvent.AfterContentChecked - OnCheck.onCheck() => DoCheck.doCheck() - OnChange.onChange() => OnChanges.onChanges() - OnAllChangesDone.onAllChangesDone() => AfterContentChecked.afterContentChecked Closes #3851
This commit is contained in:
parent
ac3f5106e4
commit
551d9a1688
|
@ -38,11 +38,11 @@ export {
|
||||||
} from './src/core/metadata';
|
} from './src/core/metadata';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
OnAllChangesDone,
|
AfterContentChecked,
|
||||||
OnChange,
|
OnChanges,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
OnCheck
|
DoCheck
|
||||||
} from './src/core/compiler/interfaces';
|
} from './src/core/compiler/interfaces';
|
||||||
|
|
||||||
export {Class, ClassDefinition, TypeDecorator} from './src/core/util/decorators';
|
export {Class, ClassDefinition, TypeDecorator} from './src/core/util/decorators';
|
||||||
|
|
|
@ -84,7 +84,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
||||||
var s = _scope_check(this.id, throwOnChange);
|
var s = _scope_check(this.id, throwOnChange);
|
||||||
this.detectChangesInRecords(throwOnChange);
|
this.detectChangesInRecords(throwOnChange);
|
||||||
this._detectChangesInLightDomChildren(throwOnChange);
|
this._detectChangesInLightDomChildren(throwOnChange);
|
||||||
if (throwOnChange === false) this.callOnAllChangesDone();
|
if (throwOnChange === false) this.callAfterContentChecked();
|
||||||
this._detectChangesInShadowDomChildren(throwOnChange);
|
this._detectChangesInShadowDomChildren(throwOnChange);
|
||||||
if (this.mode === ChangeDetectionStrategy.CheckOnce)
|
if (this.mode === ChangeDetectionStrategy.CheckOnce)
|
||||||
this.mode = ChangeDetectionStrategy.Checked;
|
this.mode = ChangeDetectionStrategy.Checked;
|
||||||
|
@ -156,7 +156,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
||||||
|
|
||||||
hydrated(): boolean { return this.context !== null; }
|
hydrated(): boolean { return this.context !== null; }
|
||||||
|
|
||||||
callOnAllChangesDone(): void { this.dispatcher.notifyOnAllChangesDone(); }
|
callAfterContentChecked(): void { this.dispatcher.notifyAfterContentChecked(); }
|
||||||
|
|
||||||
_detectChangesInLightDomChildren(throwOnChange: boolean): void {
|
_detectChangesInLightDomChildren(throwOnChange: boolean): void {
|
||||||
var c = this.lightDomChildren;
|
var c = this.lightDomChildren;
|
||||||
|
|
|
@ -39,8 +39,8 @@ export class BindingRecord {
|
||||||
|
|
||||||
isDirectiveLifecycle(): boolean { return this.mode === DIRECTIVE_LIFECYCLE; }
|
isDirectiveLifecycle(): boolean { return this.mode === DIRECTIVE_LIFECYCLE; }
|
||||||
|
|
||||||
callOnChange(): boolean {
|
callOnChanges(): boolean {
|
||||||
return isPresent(this.directiveRecord) && this.directiveRecord.callOnChange;
|
return isPresent(this.directiveRecord) && this.directiveRecord.callOnChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
isDefaultChangeDetection(): boolean {
|
isDefaultChangeDetection(): boolean {
|
||||||
|
@ -48,16 +48,17 @@ export class BindingRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static createDirectiveOnCheck(directiveRecord: DirectiveRecord): BindingRecord {
|
static createDirectiveDoCheck(directiveRecord: DirectiveRecord): BindingRecord {
|
||||||
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "onCheck", directiveRecord);
|
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "DoCheck", directiveRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
static createDirectiveOnInit(directiveRecord: DirectiveRecord): BindingRecord {
|
static createDirectiveOnInit(directiveRecord: DirectiveRecord): BindingRecord {
|
||||||
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "onInit", directiveRecord);
|
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "OnInit", directiveRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
static createDirectiveOnChange(directiveRecord: DirectiveRecord): BindingRecord {
|
static createDirectiveOnChanges(directiveRecord: DirectiveRecord): BindingRecord {
|
||||||
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "onChange", directiveRecord);
|
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "OnChanges",
|
||||||
|
directiveRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ export class ChangeDetectorJITGenerator {
|
||||||
|
|
||||||
${this._genCheckNoChanges()}
|
${this._genCheckNoChanges()}
|
||||||
|
|
||||||
${this._maybeGenCallOnAllChangesDone()}
|
${this._maybeGenCallAfterContentChecked()}
|
||||||
|
|
||||||
${this._maybeGenHydrateDirectives()}
|
${this._maybeGenHydrateDirectives()}
|
||||||
|
|
||||||
|
@ -172,23 +172,23 @@ export class ChangeDetectorJITGenerator {
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
_maybeGenCallOnAllChangesDone(): string {
|
_maybeGenCallAfterContentChecked(): string {
|
||||||
var notifications = [];
|
var notifications = [];
|
||||||
var dirs = this.directiveRecords;
|
var dirs = this.directiveRecords;
|
||||||
|
|
||||||
// NOTE(kegluneq): Order is important!
|
// NOTE(kegluneq): Order is important!
|
||||||
for (var i = dirs.length - 1; i >= 0; --i) {
|
for (var i = dirs.length - 1; i >= 0; --i) {
|
||||||
var dir = dirs[i];
|
var dir = dirs[i];
|
||||||
if (dir.callOnAllChangesDone) {
|
if (dir.callAfterContentChecked) {
|
||||||
notifications.push(
|
notifications.push(
|
||||||
`${this._names.getDirectiveName(dir.directiveIndex)}.onAllChangesDone();`);
|
`${this._names.getDirectiveName(dir.directiveIndex)}.afterContentChecked();`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notifications.length > 0) {
|
if (notifications.length > 0) {
|
||||||
var directiveNotifications = notifications.join("\n");
|
var directiveNotifications = notifications.join("\n");
|
||||||
return `
|
return `
|
||||||
${this._typeName}.prototype.callOnAllChangesDone = function() {
|
${this._typeName}.prototype.callAfterContentChecked = function() {
|
||||||
${ABSTRACT_CHANGE_DETECTOR}.prototype.callOnAllChangesDone.call(this);
|
${ABSTRACT_CHANGE_DETECTOR}.prototype.callAfterContentChecked.call(this);
|
||||||
${directiveNotifications}
|
${directiveNotifications}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@ -214,11 +214,11 @@ export class ChangeDetectorJITGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
_genDirectiveLifecycle(r: ProtoRecord): string {
|
_genDirectiveLifecycle(r: ProtoRecord): string {
|
||||||
if (r.name === "onCheck") {
|
if (r.name === "DoCheck") {
|
||||||
return this._genOnCheck(r);
|
return this._genOnCheck(r);
|
||||||
} else if (r.name === "onInit") {
|
} else if (r.name === "OnInit") {
|
||||||
return this._genOnInit(r);
|
return this._genOnInit(r);
|
||||||
} else if (r.name === "onChange") {
|
} else if (r.name === "OnChanges") {
|
||||||
return this._genOnChange(r);
|
return this._genOnChange(r);
|
||||||
} else {
|
} else {
|
||||||
throw new BaseException(`Unknown lifecycle event '${r.name}'`);
|
throw new BaseException(`Unknown lifecycle event '${r.name}'`);
|
||||||
|
@ -337,7 +337,7 @@ export class ChangeDetectorJITGenerator {
|
||||||
_genAddToChanges(r: ProtoRecord): string {
|
_genAddToChanges(r: ProtoRecord): string {
|
||||||
var newValue = this._names.getLocalName(r.selfIndex);
|
var newValue = this._names.getLocalName(r.selfIndex);
|
||||||
var oldValue = this._names.getFieldName(r.selfIndex);
|
var oldValue = this._names.getFieldName(r.selfIndex);
|
||||||
if (!r.bindingRecord.callOnChange()) return "";
|
if (!r.bindingRecord.callOnChanges()) return "";
|
||||||
return `${CHANGES_LOCAL} = this.addChange(${CHANGES_LOCAL}, ${oldValue}, ${newValue});`;
|
return `${CHANGES_LOCAL} = this.addChange(${CHANGES_LOCAL}, ${oldValue}, ${newValue});`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ export class ChangeDetectorJITGenerator {
|
||||||
|
|
||||||
_genOnCheck(r: ProtoRecord): string {
|
_genOnCheck(r: ProtoRecord): string {
|
||||||
var br = r.bindingRecord;
|
var br = r.bindingRecord;
|
||||||
return `if (!throwOnChange) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onCheck();`;
|
return `if (!throwOnChange) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.doCheck();`;
|
||||||
}
|
}
|
||||||
|
|
||||||
_genOnInit(r: ProtoRecord): string {
|
_genOnInit(r: ProtoRecord): string {
|
||||||
|
@ -370,7 +370,7 @@ export class ChangeDetectorJITGenerator {
|
||||||
|
|
||||||
_genOnChange(r: ProtoRecord): string {
|
_genOnChange(r: ProtoRecord): string {
|
||||||
var br = r.bindingRecord;
|
var br = r.bindingRecord;
|
||||||
return `if (!throwOnChange && ${CHANGES_LOCAL}) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onChange(${CHANGES_LOCAL});`;
|
return `if (!throwOnChange && ${CHANGES_LOCAL}) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onChanges(${CHANGES_LOCAL});`;
|
||||||
}
|
}
|
||||||
|
|
||||||
_genNotifyOnPushDetectors(r: ProtoRecord): string {
|
_genNotifyOnPushDetectors(r: ProtoRecord): string {
|
||||||
|
|
|
@ -9,25 +9,25 @@ export class DirectiveIndex {
|
||||||
|
|
||||||
export class DirectiveRecord {
|
export class DirectiveRecord {
|
||||||
directiveIndex: DirectiveIndex;
|
directiveIndex: DirectiveIndex;
|
||||||
callOnAllChangesDone: boolean;
|
callAfterContentChecked: boolean;
|
||||||
callOnChange: boolean;
|
callOnChanges: boolean;
|
||||||
callOnCheck: boolean;
|
callDoCheck: boolean;
|
||||||
callOnInit: boolean;
|
callOnInit: boolean;
|
||||||
changeDetection: ChangeDetectionStrategy;
|
changeDetection: ChangeDetectionStrategy;
|
||||||
|
|
||||||
constructor({directiveIndex, callOnAllChangesDone, callOnChange, callOnCheck, callOnInit,
|
constructor({directiveIndex, callAfterContentChecked, callOnChanges, callDoCheck, callOnInit,
|
||||||
changeDetection}: {
|
changeDetection}: {
|
||||||
directiveIndex?: DirectiveIndex,
|
directiveIndex?: DirectiveIndex,
|
||||||
callOnAllChangesDone?: boolean,
|
callAfterContentChecked?: boolean,
|
||||||
callOnChange?: boolean,
|
callOnChanges?: boolean,
|
||||||
callOnCheck?: boolean,
|
callDoCheck?: boolean,
|
||||||
callOnInit?: boolean,
|
callOnInit?: boolean,
|
||||||
changeDetection?: ChangeDetectionStrategy
|
changeDetection?: ChangeDetectionStrategy
|
||||||
} = {}) {
|
} = {}) {
|
||||||
this.directiveIndex = directiveIndex;
|
this.directiveIndex = directiveIndex;
|
||||||
this.callOnAllChangesDone = normalizeBool(callOnAllChangesDone);
|
this.callAfterContentChecked = normalizeBool(callAfterContentChecked);
|
||||||
this.callOnChange = normalizeBool(callOnChange);
|
this.callOnChanges = normalizeBool(callOnChanges);
|
||||||
this.callOnCheck = normalizeBool(callOnCheck);
|
this.callDoCheck = normalizeBool(callDoCheck);
|
||||||
this.callOnInit = normalizeBool(callOnInit);
|
this.callOnInit = normalizeBool(callOnInit);
|
||||||
this.changeDetection = changeDetection;
|
this.changeDetection = changeDetection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,12 +133,12 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proto.isLifeCycleRecord()) {
|
if (proto.isLifeCycleRecord()) {
|
||||||
if (proto.name === "onCheck" && !throwOnChange) {
|
if (proto.name === "DoCheck" && !throwOnChange) {
|
||||||
this._getDirectiveFor(directiveRecord.directiveIndex).onCheck();
|
this._getDirectiveFor(directiveRecord.directiveIndex).doCheck();
|
||||||
} else if (proto.name === "onInit" && !throwOnChange && !this.alreadyChecked) {
|
} else if (proto.name === "OnInit" && !throwOnChange && !this.alreadyChecked) {
|
||||||
this._getDirectiveFor(directiveRecord.directiveIndex).onInit();
|
this._getDirectiveFor(directiveRecord.directiveIndex).onInit();
|
||||||
} else if (proto.name === "onChange" && isPresent(changes) && !throwOnChange) {
|
} else if (proto.name === "OnChanges" && isPresent(changes) && !throwOnChange) {
|
||||||
this._getDirectiveFor(directiveRecord.directiveIndex).onChange(changes);
|
this._getDirectiveFor(directiveRecord.directiveIndex).onChanges(changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -168,13 +168,13 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||||
return isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
|
return isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
callOnAllChangesDone() {
|
callAfterContentChecked() {
|
||||||
super.callOnAllChangesDone();
|
super.callAfterContentChecked();
|
||||||
var dirs = this.directiveRecords;
|
var dirs = this.directiveRecords;
|
||||||
for (var i = dirs.length - 1; i >= 0; --i) {
|
for (var i = dirs.length - 1; i >= 0; --i) {
|
||||||
var dir = dirs[i];
|
var dir = dirs[i];
|
||||||
if (dir.callOnAllChangesDone) {
|
if (dir.callAfterContentChecked) {
|
||||||
this._getDirectiveFor(dir.directiveIndex).onAllChangesDone();
|
this._getDirectiveFor(dir.directiveIndex).afterContentChecked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
_addChange(bindingRecord: BindingRecord, change, changes) {
|
_addChange(bindingRecord: BindingRecord, change, changes) {
|
||||||
if (bindingRecord.callOnChange()) {
|
if (bindingRecord.callOnChanges()) {
|
||||||
return super.addChange(changes, change.previousValue, change.currentValue);
|
return super.addChange(changes, change.previousValue, change.currentValue);
|
||||||
} else {
|
} else {
|
||||||
return changes;
|
return changes;
|
||||||
|
|
|
@ -51,7 +51,7 @@ export interface ChangeDispatcher {
|
||||||
getDebugContext(elementIndex: number, directiveIndex: DirectiveIndex): DebugContext;
|
getDebugContext(elementIndex: number, directiveIndex: DirectiveIndex): DebugContext;
|
||||||
notifyOnBinding(bindingTarget: BindingTarget, value: any): void;
|
notifyOnBinding(bindingTarget: BindingTarget, value: any): void;
|
||||||
logBindingUpdate(bindingTarget: BindingTarget, value: any): void;
|
logBindingUpdate(bindingTarget: BindingTarget, value: any): void;
|
||||||
notifyOnAllChangesDone(): void;
|
notifyAfterContentChecked(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChangeDetector {
|
export interface ChangeDetector {
|
||||||
|
|
|
@ -13,15 +13,15 @@ bool hasLifecycleHook(LifecycleEvent e, type, DirectiveMetadata annotation) {
|
||||||
final List interfaces = reflector.interfaces(type);
|
final List interfaces = reflector.interfaces(type);
|
||||||
var interface;
|
var interface;
|
||||||
|
|
||||||
if (e == LifecycleEvent.onChange) {
|
if (e == LifecycleEvent.OnChanges) {
|
||||||
interface = OnChange;
|
interface = OnChanges;
|
||||||
} else if (e == LifecycleEvent.onDestroy) {
|
} else if (e == LifecycleEvent.OnDestroy) {
|
||||||
interface = OnDestroy;
|
interface = OnDestroy;
|
||||||
} else if (e == LifecycleEvent.onAllChangesDone) {
|
} else if (e == LifecycleEvent.AfterContentChecked) {
|
||||||
interface = OnAllChangesDone;
|
interface = AfterContentChecked;
|
||||||
} else if (e == LifecycleEvent.onCheck) {
|
} else if (e == LifecycleEvent.DoCheck) {
|
||||||
interface = OnCheck;
|
interface = DoCheck;
|
||||||
} else if (e == LifecycleEvent.onInit) {
|
} else if (e == LifecycleEvent.OnInit) {
|
||||||
interface = OnInit;
|
interface = OnInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,15 @@ export function hasLifecycleHook(e: LifecycleEvent, type, annotation: DirectiveM
|
||||||
if (!(type instanceof Type)) return false;
|
if (!(type instanceof Type)) return false;
|
||||||
var proto = (<any>type).prototype;
|
var proto = (<any>type).prototype;
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case LifecycleEvent.onAllChangesDone:
|
case LifecycleEvent.AfterContentChecked:
|
||||||
return !!proto.onAllChangesDone;
|
return !!proto.afterContentChecked;
|
||||||
case LifecycleEvent.onChange:
|
case LifecycleEvent.OnChanges:
|
||||||
return !!proto.onChange;
|
return !!proto.onChanges;
|
||||||
case LifecycleEvent.onCheck:
|
case LifecycleEvent.DoCheck:
|
||||||
return !!proto.onCheck;
|
return !!proto.doCheck;
|
||||||
case LifecycleEvent.onDestroy:
|
case LifecycleEvent.OnDestroy:
|
||||||
return !!proto.onDestroy;
|
return !!proto.onDestroy;
|
||||||
case LifecycleEvent.onInit:
|
case LifecycleEvent.OnInit:
|
||||||
return !!proto.onInit;
|
return !!proto.onInit;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -204,9 +204,9 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||||
|
|
||||||
get callOnDestroy(): boolean { return this.metadata.callOnDestroy; }
|
get callOnDestroy(): boolean { return this.metadata.callOnDestroy; }
|
||||||
|
|
||||||
get callOnChange(): boolean { return this.metadata.callOnChange; }
|
get callOnChanges(): boolean { return this.metadata.callOnChanges; }
|
||||||
|
|
||||||
get callOnAllChangesDone(): boolean { return this.metadata.callOnAllChangesDone; }
|
get callAfterContentChecked(): boolean { return this.metadata.callAfterContentChecked; }
|
||||||
|
|
||||||
get displayName(): string { return this.key.displayName; }
|
get displayName(): string { return this.key.displayName; }
|
||||||
|
|
||||||
|
@ -238,11 +238,12 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||||
properties: ann.properties,
|
properties: ann.properties,
|
||||||
readAttributes: DirectiveBinding._readAttributes(deps),
|
readAttributes: DirectiveBinding._readAttributes(deps),
|
||||||
|
|
||||||
callOnDestroy: hasLifecycleHook(LifecycleEvent.onDestroy, rb.key.token, ann),
|
callOnDestroy: hasLifecycleHook(LifecycleEvent.OnDestroy, rb.key.token, ann),
|
||||||
callOnChange: hasLifecycleHook(LifecycleEvent.onChange, rb.key.token, ann),
|
callOnChanges: hasLifecycleHook(LifecycleEvent.OnChanges, rb.key.token, ann),
|
||||||
callOnCheck: hasLifecycleHook(LifecycleEvent.onCheck, rb.key.token, ann),
|
callDoCheck: hasLifecycleHook(LifecycleEvent.DoCheck, rb.key.token, ann),
|
||||||
callOnInit: hasLifecycleHook(LifecycleEvent.onInit, rb.key.token, ann),
|
callOnInit: hasLifecycleHook(LifecycleEvent.OnInit, rb.key.token, ann),
|
||||||
callOnAllChangesDone: hasLifecycleHook(LifecycleEvent.onAllChangesDone, rb.key.token, ann),
|
callAfterContentChecked:
|
||||||
|
hasLifecycleHook(LifecycleEvent.AfterContentChecked, rb.key.token, ann),
|
||||||
|
|
||||||
changeDetection: ann instanceof ComponentMetadata ? ann.changeDetection : null,
|
changeDetection: ann instanceof ComponentMetadata ? ann.changeDetection : null,
|
||||||
|
|
||||||
|
@ -431,7 +432,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
|
||||||
this._strategy.dehydrate();
|
this._strategy.dehydrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
onAllChangesDone(): void {
|
afterContentChecked(): void {
|
||||||
if (isPresent(this._query0) && this._query0.originator === this) {
|
if (isPresent(this._query0) && this._query0.originator === this) {
|
||||||
this._query0.list.fireCallbacks();
|
this._query0.list.fireCallbacks();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,32 +6,32 @@ import {global} from 'angular2/src/core/facade/lang';
|
||||||
// https://github.com/systemjs/systemjs/issues/487 gets closed.
|
// https://github.com/systemjs/systemjs/issues/487 gets closed.
|
||||||
var __ignore_me = global;
|
var __ignore_me = global;
|
||||||
/**
|
/**
|
||||||
* Defines lifecycle method {@link annotations/LifeCycleEvent#onChange `LifeCycleEvent.onChange`}
|
* Defines lifecycle method {@link metadata/LifeCycleEvent#OnChanges `LifeCycleEvent.OnChanges`}
|
||||||
* called after all of component's bound properties are updated.
|
* called after all of component's bound properties are updated.
|
||||||
*/
|
*/
|
||||||
export interface OnChange { onChange(changes: StringMap<string, any>): void; }
|
export interface OnChanges { onChanges(changes: StringMap<string, any>): void; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines lifecycle method {@link annotations/LifeCycleEvent#onDestroy `LifeCycleEvent.onDestroy`}
|
* Defines lifecycle method {@link metadata/LifeCycleEvent#OnInit `LifeCycleEvent.OnInit`}
|
||||||
* called when a directive is being destroyed.
|
|
||||||
*/
|
|
||||||
export interface OnDestroy { onDestroy(): void; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines lifecycle method {@link annotations/LifeCycleEvent#onCheck `LifeCycleEvent.onCheck`}
|
|
||||||
* called when a directive is being checked.
|
|
||||||
*/
|
|
||||||
export interface OnCheck { onCheck(): void; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines lifecycle method {@link annotations/LifeCycleEvent#onInit `LifeCycleEvent.onInit`}
|
|
||||||
* called when a directive is being checked the first time.
|
* called when a directive is being checked the first time.
|
||||||
*/
|
*/
|
||||||
export interface OnInit { onInit(): void; }
|
export interface OnInit { onInit(): void; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines lifecycle method
|
* Defines lifecycle method {@link metadata/LifeCycleEvent#DoCheck `LifeCycleEvent.DoCheck`}
|
||||||
* {@link annotations/LifeCycleEvent#onAllChangesDone `LifeCycleEvent.onAllChangesDone`}
|
* called when a directive is being checked.
|
||||||
* called when the bindings of all its children have been changed.
|
|
||||||
*/
|
*/
|
||||||
export interface OnAllChangesDone { onAllChangesDone(): void; }
|
export interface DoCheck { doCheck(): boolean; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines lifecycle method {@link metadata/LifeCycleEvent#OnDestroy `LifeCycleEvent.OnDestroy`}
|
||||||
|
* called when a directive is being destroyed.
|
||||||
|
*/
|
||||||
|
export interface OnDestroy { onDestroy(): void; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines lifecycle method
|
||||||
|
* {@link metadata/LifeCycleEvent#AfterContentChecked `LifeCycleEvent.afterContentChecked`}
|
||||||
|
* called when the bindings of all its view children have been changed.
|
||||||
|
*/
|
||||||
|
export interface AfterContentChecked { afterContentChecked(): void; }
|
||||||
|
|
|
@ -150,14 +150,14 @@ export class BindingRecordsCreator {
|
||||||
BindingRecord.createForDirective(astWithSource, propertyName, setter, directiveRecord));
|
BindingRecord.createForDirective(astWithSource, propertyName, setter, directiveRecord));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (directiveRecord.callOnChange) {
|
if (directiveRecord.callOnChanges) {
|
||||||
bindings.push(BindingRecord.createDirectiveOnChange(directiveRecord));
|
bindings.push(BindingRecord.createDirectiveOnChanges(directiveRecord));
|
||||||
}
|
}
|
||||||
if (directiveRecord.callOnInit) {
|
if (directiveRecord.callOnInit) {
|
||||||
bindings.push(BindingRecord.createDirectiveOnInit(directiveRecord));
|
bindings.push(BindingRecord.createDirectiveOnInit(directiveRecord));
|
||||||
}
|
}
|
||||||
if (directiveRecord.callOnCheck) {
|
if (directiveRecord.callDoCheck) {
|
||||||
bindings.push(BindingRecord.createDirectiveOnCheck(directiveRecord));
|
bindings.push(BindingRecord.createDirectiveDoCheck(directiveRecord));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,9 +191,9 @@ export class BindingRecordsCreator {
|
||||||
this._directiveRecordsMap.set(
|
this._directiveRecordsMap.set(
|
||||||
id, new DirectiveRecord({
|
id, new DirectiveRecord({
|
||||||
directiveIndex: new DirectiveIndex(boundElementIndex, directiveIndex),
|
directiveIndex: new DirectiveIndex(boundElementIndex, directiveIndex),
|
||||||
callOnAllChangesDone: directiveMetadata.callOnAllChangesDone,
|
callAfterContentChecked: directiveMetadata.callAfterContentChecked,
|
||||||
callOnChange: directiveMetadata.callOnChange,
|
callOnChanges: directiveMetadata.callOnChanges,
|
||||||
callOnCheck: directiveMetadata.callOnCheck,
|
callDoCheck: directiveMetadata.callDoCheck,
|
||||||
callOnInit: directiveMetadata.callOnInit,
|
callOnInit: directiveMetadata.callOnInit,
|
||||||
changeDetection: directiveMetadata.changeDetection
|
changeDetection: directiveMetadata.changeDetection
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -204,11 +204,11 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyOnAllChangesDone(): void {
|
notifyAfterContentChecked(): void {
|
||||||
var eiCount = this.proto.elementBinders.length;
|
var eiCount = this.proto.elementBinders.length;
|
||||||
var ei = this.elementInjectors;
|
var ei = this.elementInjectors;
|
||||||
for (var i = eiCount - 1; i >= 0; i--) {
|
for (var i = eiCount - 1; i >= 0; i--) {
|
||||||
if (isPresent(ei[i + this.elementOffset])) ei[i + this.elementOffset].onAllChangesDone();
|
if (isPresent(ei[i + this.elementOffset])) ei[i + this.elementOffset].afterContentChecked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {
|
||||||
*/
|
*/
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[ng-class]',
|
selector: '[ng-class]',
|
||||||
lifecycle: [LifecycleEvent.onCheck, LifecycleEvent.onDestroy],
|
lifecycle: [LifecycleEvent.DoCheck, LifecycleEvent.OnDestroy],
|
||||||
properties: ['rawClass: ng-class', 'initialClasses: class']
|
properties: ['rawClass: ng-class', 'initialClasses: class']
|
||||||
})
|
})
|
||||||
export class NgClass {
|
export class NgClass {
|
||||||
|
@ -76,7 +76,7 @@ export class NgClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCheck(): void {
|
doCheck(): void {
|
||||||
if (isPresent(this._differ)) {
|
if (isPresent(this._differ)) {
|
||||||
var changes = this._differ.diff(this._rawClass);
|
var changes = this._differ.diff(this._rawClass);
|
||||||
if (isPresent(changes)) {
|
if (isPresent(changes)) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import {isPresent, isBlank} from 'angular2/src/core/facade/lang';
|
||||||
* - `<template ng-for #item [ng-for-of]="items" #i="index"><li>...</li></template>`
|
* - `<template ng-for #item [ng-for-of]="items" #i="index"><li>...</li></template>`
|
||||||
*/
|
*/
|
||||||
@Directive(
|
@Directive(
|
||||||
{selector: '[ng-for][ng-for-of]', properties: ['ngForOf'], lifecycle: [LifecycleEvent.onCheck]})
|
{selector: '[ng-for][ng-for-of]', properties: ['ngForOf'], lifecycle: [LifecycleEvent.DoCheck]})
|
||||||
export class NgFor {
|
export class NgFor {
|
||||||
_ngForOf: any;
|
_ngForOf: any;
|
||||||
private _differ: IterableDiffer;
|
private _differ: IterableDiffer;
|
||||||
|
@ -49,7 +49,7 @@ export class NgFor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCheck() {
|
doCheck() {
|
||||||
if (isPresent(this._differ)) {
|
if (isPresent(this._differ)) {
|
||||||
var changes = this._differ.diff(this._ngForOf);
|
var changes = this._differ.diff(this._ngForOf);
|
||||||
if (isPresent(changes)) this._applyChanges(changes);
|
if (isPresent(changes)) this._applyChanges(changes);
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {Renderer} from 'angular2/src/core/render/api';
|
||||||
*/
|
*/
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[ng-style]',
|
selector: '[ng-style]',
|
||||||
lifecycle: [LifecycleEvent.onCheck],
|
lifecycle: [LifecycleEvent.DoCheck],
|
||||||
properties: ['rawStyle: ng-style']
|
properties: ['rawStyle: ng-style']
|
||||||
})
|
})
|
||||||
export class NgStyle {
|
export class NgStyle {
|
||||||
|
@ -44,7 +44,7 @@ export class NgStyle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCheck() {
|
doCheck() {
|
||||||
if (isPresent(this._differ)) {
|
if (isPresent(this._differ)) {
|
||||||
var changes = this._differ.diff(this._rawStyle);
|
var changes = this._differ.diff(this._rawStyle);
|
||||||
if (isPresent(changes)) {
|
if (isPresent(changes)) {
|
||||||
|
|
|
@ -850,12 +850,37 @@ export class ComponentMetadata extends DirectiveMetadata {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lifecycle events are guaranteed to be called in the following order:
|
* Lifecycle events are guaranteed to be called in the following order:
|
||||||
* - `onChange` (optional if any bindings have changed),
|
* - `OnChanges` (if any bindings have changed),
|
||||||
* - `onInit` (optional after the first check only),
|
* - `OnInit` (after the first check only),
|
||||||
* - `onCheck`,
|
* - `DoCheck`,
|
||||||
* - `onAllChangesDone`
|
* - `AfterContentChecked`
|
||||||
|
* - `AfterContentChecked`
|
||||||
|
* - `OnDestroy` (at the very end before destruction)
|
||||||
*/
|
*/
|
||||||
export enum LifecycleEvent {
|
export enum LifecycleEvent {
|
||||||
|
/**
|
||||||
|
* Notify a directive when it has been checked the first time.
|
||||||
|
*
|
||||||
|
* This method is called right after the directive's bindings have been checked,
|
||||||
|
* and before any of its children's bindings have been checked.
|
||||||
|
*
|
||||||
|
* It is invoked only once.
|
||||||
|
*
|
||||||
|
* ## Example
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* @Directive({
|
||||||
|
* selector: '[class-set]',
|
||||||
|
* lifecycle: [LifecycleEvent.OnInit]
|
||||||
|
* })
|
||||||
|
* class ClassSet {
|
||||||
|
* onInit() {
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
OnInit,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify a directive whenever a {@link ViewMetadata} that contains it is destroyed.
|
* Notify a directive whenever a {@link ViewMetadata} that contains it is destroyed.
|
||||||
*
|
*
|
||||||
|
@ -864,7 +889,7 @@ export enum LifecycleEvent {
|
||||||
* ```
|
* ```
|
||||||
* @Directive({
|
* @Directive({
|
||||||
* ...,
|
* ...,
|
||||||
* lifecycle: [LifecycleEvent.onDestroy]
|
* lifecycle: [LifecycleEvent.OnDestroy]
|
||||||
* })
|
* })
|
||||||
* class ClassSet {
|
* class ClassSet {
|
||||||
* onDestroy() {
|
* onDestroy() {
|
||||||
|
@ -873,7 +898,7 @@ export enum LifecycleEvent {
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
onDestroy,
|
OnDestroy,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -893,12 +918,12 @@ export enum LifecycleEvent {
|
||||||
* 'propA',
|
* 'propA',
|
||||||
* 'propB'
|
* 'propB'
|
||||||
* ],
|
* ],
|
||||||
* lifecycle: [LifecycleEvent.onChange]
|
* lifecycle: [LifecycleEvent.OnChanges]
|
||||||
* })
|
* })
|
||||||
* class ClassSet {
|
* class ClassSet {
|
||||||
* propA;
|
* propA;
|
||||||
* propB;
|
* propB;
|
||||||
* onChange(changes:{[idx: string, PropertyUpdate]}) {
|
* onChanges(changes:{[idx: string, PropertyUpdate]}) {
|
||||||
* // This will get called after any of the properties have been updated.
|
* // This will get called after any of the properties have been updated.
|
||||||
* if (changes['propA']) {
|
* if (changes['propA']) {
|
||||||
* // if propA was updated
|
* // if propA was updated
|
||||||
|
@ -910,7 +935,7 @@ export enum LifecycleEvent {
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
onChange,
|
OnChanges,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify a directive when it has been checked.
|
* Notify a directive when it has been checked.
|
||||||
|
@ -925,59 +950,36 @@ export enum LifecycleEvent {
|
||||||
* ```
|
* ```
|
||||||
* @Directive({
|
* @Directive({
|
||||||
* selector: '[class-set]',
|
* selector: '[class-set]',
|
||||||
* lifecycle: [LifecycleEvent.onCheck]
|
* lifecycle: [LifecycleEvent.DoCheck]
|
||||||
* })
|
* })
|
||||||
* class ClassSet {
|
* class ClassSet {
|
||||||
* onCheck() {
|
* doCheck() {
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
onCheck,
|
DoCheck,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify a directive when it has been checked the first itme.
|
* Notify a directive when the bindings of all its view children have been checked (whether they
|
||||||
*
|
* have changed or not).
|
||||||
* This method is called right after the directive's bindings have been checked,
|
|
||||||
* and before any of its children's bindings have been checked.
|
|
||||||
*
|
|
||||||
* It is invoked only once.
|
|
||||||
*
|
*
|
||||||
* ## Example
|
* ## Example
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @Directive({
|
* @Directive({
|
||||||
* selector: '[class-set]',
|
* selector: '[class-set]',
|
||||||
* lifecycle: [LifecycleEvent.onInit]
|
* lifecycle: [LifecycleEvent.AfterContentChecked]
|
||||||
* })
|
|
||||||
* class ClassSet {
|
|
||||||
* onInit() {
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
onInit,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify a directive when the bindings of all its children have been checked (whether they have
|
|
||||||
* changed or not).
|
|
||||||
*
|
|
||||||
* ## Example
|
|
||||||
*
|
|
||||||
* ```
|
|
||||||
* @Directive({
|
|
||||||
* selector: '[class-set]',
|
|
||||||
* lifecycle: [LifecycleEvent.onAllChangesDone]
|
|
||||||
* })
|
* })
|
||||||
* class ClassSet {
|
* class ClassSet {
|
||||||
*
|
*
|
||||||
* onAllChangesDone() {
|
* afterContentChecked() {
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
onAllChangesDone
|
AfterContentChecked
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -154,10 +154,10 @@ export class RenderDirectiveMetadata {
|
||||||
readAttributes: List<string>;
|
readAttributes: List<string>;
|
||||||
type: number;
|
type: number;
|
||||||
callOnDestroy: boolean;
|
callOnDestroy: boolean;
|
||||||
callOnChange: boolean;
|
callOnChanges: boolean;
|
||||||
callOnCheck: boolean;
|
callDoCheck: boolean;
|
||||||
callOnInit: boolean;
|
callOnInit: boolean;
|
||||||
callOnAllChangesDone: boolean;
|
callAfterContentChecked: boolean;
|
||||||
changeDetection: ChangeDetectionStrategy;
|
changeDetection: ChangeDetectionStrategy;
|
||||||
exportAs: string;
|
exportAs: string;
|
||||||
hostListeners: Map<string, string>;
|
hostListeners: Map<string, string>;
|
||||||
|
@ -168,8 +168,8 @@ export class RenderDirectiveMetadata {
|
||||||
private static _hostRegExp = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))$/g;
|
private static _hostRegExp = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))$/g;
|
||||||
|
|
||||||
constructor({id, selector, compileChildren, events, hostListeners, hostProperties, hostAttributes,
|
constructor({id, selector, compileChildren, events, hostListeners, hostProperties, hostAttributes,
|
||||||
properties, readAttributes, type, callOnDestroy, callOnChange, callOnCheck,
|
properties, readAttributes, type, callOnDestroy, callOnChanges, callDoCheck,
|
||||||
callOnInit, callOnAllChangesDone, changeDetection, exportAs}: {
|
callOnInit, callAfterContentChecked, changeDetection, exportAs}: {
|
||||||
id?: string,
|
id?: string,
|
||||||
selector?: string,
|
selector?: string,
|
||||||
compileChildren?: boolean,
|
compileChildren?: boolean,
|
||||||
|
@ -181,10 +181,10 @@ export class RenderDirectiveMetadata {
|
||||||
readAttributes?: List<string>,
|
readAttributes?: List<string>,
|
||||||
type?: number,
|
type?: number,
|
||||||
callOnDestroy?: boolean,
|
callOnDestroy?: boolean,
|
||||||
callOnChange?: boolean,
|
callOnChanges?: boolean,
|
||||||
callOnCheck?: boolean,
|
callDoCheck?: boolean,
|
||||||
callOnInit?: boolean,
|
callOnInit?: boolean,
|
||||||
callOnAllChangesDone?: boolean,
|
callAfterContentChecked?: boolean,
|
||||||
changeDetection?: ChangeDetectionStrategy,
|
changeDetection?: ChangeDetectionStrategy,
|
||||||
exportAs?: string
|
exportAs?: string
|
||||||
}) {
|
}) {
|
||||||
|
@ -199,16 +199,16 @@ export class RenderDirectiveMetadata {
|
||||||
this.readAttributes = readAttributes;
|
this.readAttributes = readAttributes;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.callOnDestroy = callOnDestroy;
|
this.callOnDestroy = callOnDestroy;
|
||||||
this.callOnChange = callOnChange;
|
this.callOnChanges = callOnChanges;
|
||||||
this.callOnCheck = callOnCheck;
|
this.callDoCheck = callDoCheck;
|
||||||
this.callOnInit = callOnInit;
|
this.callOnInit = callOnInit;
|
||||||
this.callOnAllChangesDone = callOnAllChangesDone;
|
this.callAfterContentChecked = callAfterContentChecked;
|
||||||
this.changeDetection = changeDetection;
|
this.changeDetection = changeDetection;
|
||||||
this.exportAs = exportAs;
|
this.exportAs = exportAs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create({id, selector, compileChildren, events, host, properties, readAttributes, type,
|
static create({id, selector, compileChildren, events, host, properties, readAttributes, type,
|
||||||
callOnDestroy, callOnChange, callOnCheck, callOnInit, callOnAllChangesDone,
|
callOnDestroy, callOnChanges, callDoCheck, callOnInit, callAfterContentChecked,
|
||||||
changeDetection, exportAs}: {
|
changeDetection, exportAs}: {
|
||||||
id?: string,
|
id?: string,
|
||||||
selector?: string,
|
selector?: string,
|
||||||
|
@ -219,10 +219,10 @@ export class RenderDirectiveMetadata {
|
||||||
readAttributes?: List<string>,
|
readAttributes?: List<string>,
|
||||||
type?: number,
|
type?: number,
|
||||||
callOnDestroy?: boolean,
|
callOnDestroy?: boolean,
|
||||||
callOnChange?: boolean,
|
callOnChanges?: boolean,
|
||||||
callOnCheck?: boolean,
|
callDoCheck?: boolean,
|
||||||
callOnInit?: boolean,
|
callOnInit?: boolean,
|
||||||
callOnAllChangesDone?: boolean,
|
callAfterContentChecked?: boolean,
|
||||||
changeDetection?: ChangeDetectionStrategy,
|
changeDetection?: ChangeDetectionStrategy,
|
||||||
exportAs?: string
|
exportAs?: string
|
||||||
}): RenderDirectiveMetadata {
|
}): RenderDirectiveMetadata {
|
||||||
|
@ -255,10 +255,10 @@ export class RenderDirectiveMetadata {
|
||||||
readAttributes: readAttributes,
|
readAttributes: readAttributes,
|
||||||
type: type,
|
type: type,
|
||||||
callOnDestroy: callOnDestroy,
|
callOnDestroy: callOnDestroy,
|
||||||
callOnChange: callOnChange,
|
callOnChanges: callOnChanges,
|
||||||
callOnCheck: callOnCheck,
|
callDoCheck: callDoCheck,
|
||||||
callOnInit: callOnInit,
|
callOnInit: callOnInit,
|
||||||
callOnAllChangesDone: callOnAllChangesDone,
|
callAfterContentChecked: callAfterContentChecked,
|
||||||
changeDetection: changeDetection,
|
changeDetection: changeDetection,
|
||||||
exportAs: exportAs
|
exportAs: exportAs
|
||||||
});
|
});
|
||||||
|
|
|
@ -52,7 +52,7 @@ const controlGroupBinding =
|
||||||
selector: '[ng-control-group]',
|
selector: '[ng-control-group]',
|
||||||
bindings: [controlGroupBinding],
|
bindings: [controlGroupBinding],
|
||||||
properties: ['name: ng-control-group'],
|
properties: ['name: ng-control-group'],
|
||||||
lifecycle: [LifecycleEvent.onInit, LifecycleEvent.onDestroy],
|
lifecycle: [LifecycleEvent.OnInit, LifecycleEvent.OnDestroy],
|
||||||
exportAs: 'form'
|
exportAs: 'form'
|
||||||
})
|
})
|
||||||
export class NgControlGroup extends ControlContainer {
|
export class NgControlGroup extends ControlContainer {
|
||||||
|
|
|
@ -76,7 +76,7 @@ const controlNameBinding =
|
||||||
bindings: [controlNameBinding],
|
bindings: [controlNameBinding],
|
||||||
properties: ['name: ngControl', 'model: ngModel'],
|
properties: ['name: ngControl', 'model: ngModel'],
|
||||||
events: ['update: ngModel'],
|
events: ['update: ngModel'],
|
||||||
lifecycle: [LifecycleEvent.onDestroy, LifecycleEvent.onChange],
|
lifecycle: [LifecycleEvent.OnDestroy, LifecycleEvent.OnChanges],
|
||||||
exportAs: 'form'
|
exportAs: 'form'
|
||||||
})
|
})
|
||||||
export class NgControlName extends NgControl {
|
export class NgControlName extends NgControl {
|
||||||
|
@ -95,7 +95,7 @@ export class NgControlName extends NgControl {
|
||||||
this.ngValidators = ngValidators;
|
this.ngValidators = ngValidators;
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(c: StringMap<string, any>) {
|
onChanges(c: StringMap<string, any>) {
|
||||||
if (!this._added) {
|
if (!this._added) {
|
||||||
this.formDirective.addControl(this);
|
this.formDirective.addControl(this);
|
||||||
this._added = true;
|
this._added = true;
|
||||||
|
|
|
@ -63,7 +63,7 @@ const formControlBinding =
|
||||||
bindings: [formControlBinding],
|
bindings: [formControlBinding],
|
||||||
properties: ['form: ngFormControl', 'model: ngModel'],
|
properties: ['form: ngFormControl', 'model: ngModel'],
|
||||||
events: ['update: ngModel'],
|
events: ['update: ngModel'],
|
||||||
lifecycle: [LifecycleEvent.onChange],
|
lifecycle: [LifecycleEvent.OnChanges],
|
||||||
exportAs: 'form'
|
exportAs: 'form'
|
||||||
})
|
})
|
||||||
export class NgFormControl extends NgControl {
|
export class NgFormControl extends NgControl {
|
||||||
|
@ -80,7 +80,7 @@ export class NgFormControl extends NgControl {
|
||||||
this.ngValidators = ngValidators;
|
this.ngValidators = ngValidators;
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(c: StringMap<string, any>) {
|
onChanges(c: StringMap<string, any>) {
|
||||||
if (!this._added) {
|
if (!this._added) {
|
||||||
setUpControl(this.form, this);
|
setUpControl(this.form, this);
|
||||||
this.form.updateValidity();
|
this.form.updateValidity();
|
||||||
|
|
|
@ -84,7 +84,7 @@ const formDirectiveBinding =
|
||||||
selector: '[ng-form-model]',
|
selector: '[ng-form-model]',
|
||||||
bindings: [formDirectiveBinding],
|
bindings: [formDirectiveBinding],
|
||||||
properties: ['form: ng-form-model'],
|
properties: ['form: ng-form-model'],
|
||||||
lifecycle: [LifecycleEvent.onChange],
|
lifecycle: [LifecycleEvent.OnChanges],
|
||||||
host: {
|
host: {
|
||||||
'(submit)': 'onSubmit()',
|
'(submit)': 'onSubmit()',
|
||||||
},
|
},
|
||||||
|
@ -96,7 +96,7 @@ export class NgFormModel extends ControlContainer implements Form {
|
||||||
directives: List<NgControl> = [];
|
directives: List<NgControl> = [];
|
||||||
ngSubmit = new EventEmitter();
|
ngSubmit = new EventEmitter();
|
||||||
|
|
||||||
onChange(_) { this._updateDomValue(); }
|
onChanges(_) { this._updateDomValue(); }
|
||||||
|
|
||||||
get formDirective(): Form { return this; }
|
get formDirective(): Form { return this; }
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRe
|
||||||
bindings: [formControlBinding],
|
bindings: [formControlBinding],
|
||||||
properties: ['model: ngModel'],
|
properties: ['model: ngModel'],
|
||||||
events: ['update: ngModel'],
|
events: ['update: ngModel'],
|
||||||
lifecycle: [LifecycleEvent.onChange],
|
lifecycle: [LifecycleEvent.OnChanges],
|
||||||
exportAs: 'form'
|
exportAs: 'form'
|
||||||
})
|
})
|
||||||
export class NgModel extends NgControl {
|
export class NgModel extends NgControl {
|
||||||
|
@ -50,7 +50,7 @@ export class NgModel extends NgControl {
|
||||||
this.ngValidators = ngValidators;
|
this.ngValidators = ngValidators;
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(c: StringMap<string, any>) {
|
onChanges(c: StringMap<string, any>) {
|
||||||
if (!this._added) {
|
if (!this._added) {
|
||||||
setUpControl(this._control, this);
|
setUpControl(this._control, this);
|
||||||
this._control.updateValidity();
|
this._control.updateValidity();
|
||||||
|
|
|
@ -372,10 +372,10 @@ export class Serializer {
|
||||||
'readAttributes': meta.readAttributes,
|
'readAttributes': meta.readAttributes,
|
||||||
'type': meta.type,
|
'type': meta.type,
|
||||||
'callOnDestroy': meta.callOnDestroy,
|
'callOnDestroy': meta.callOnDestroy,
|
||||||
'callOnChange': meta.callOnChange,
|
'callOnChanges': meta.callOnChanges,
|
||||||
'callOnCheck': meta.callOnCheck,
|
'callDoCheck': meta.callDoCheck,
|
||||||
'callOnInit': meta.callOnInit,
|
'callOnInit': meta.callOnInit,
|
||||||
'callOnAllChangesDone': meta.callOnAllChangesDone,
|
'callAfterContentChecked': meta.callAfterContentChecked,
|
||||||
'changeDetection': meta.changeDetection,
|
'changeDetection': meta.changeDetection,
|
||||||
'exportAs': meta.exportAs,
|
'exportAs': meta.exportAs,
|
||||||
'hostProperties': this.mapToObject(meta.hostProperties),
|
'hostProperties': this.mapToObject(meta.hostProperties),
|
||||||
|
@ -397,10 +397,10 @@ export class Serializer {
|
||||||
type: obj['type'],
|
type: obj['type'],
|
||||||
exportAs: obj['exportAs'],
|
exportAs: obj['exportAs'],
|
||||||
callOnDestroy: obj['callOnDestroy'],
|
callOnDestroy: obj['callOnDestroy'],
|
||||||
callOnChange: obj['callOnChange'],
|
callOnChanges: obj['callOnChanges'],
|
||||||
callOnCheck: obj['callOnCheck'],
|
callDoCheck: obj['callDoCheck'],
|
||||||
callOnInit: obj['callOnInit'],
|
callOnInit: obj['callOnInit'],
|
||||||
callOnAllChangesDone: obj['callOnAllChangesDone'],
|
callAfterContentChecked: obj['callAfterContentChecked'],
|
||||||
changeDetection: obj['changeDetection'],
|
changeDetection: obj['changeDetection'],
|
||||||
events: obj['events']
|
events: obj['events']
|
||||||
});
|
});
|
||||||
|
|
|
@ -282,23 +282,23 @@ class _DirectiveUpdating {
|
||||||
static basicRecords: List<DirectiveRecord> = [
|
static basicRecords: List<DirectiveRecord> = [
|
||||||
new DirectiveRecord({
|
new DirectiveRecord({
|
||||||
directiveIndex: new DirectiveIndex(0, 0),
|
directiveIndex: new DirectiveIndex(0, 0),
|
||||||
callOnChange: true,
|
callOnChanges: true,
|
||||||
callOnCheck: true,
|
callDoCheck: true,
|
||||||
callOnAllChangesDone: true
|
callAfterContentChecked: true
|
||||||
}),
|
}),
|
||||||
new DirectiveRecord({
|
new DirectiveRecord({
|
||||||
directiveIndex: new DirectiveIndex(0, 1),
|
directiveIndex: new DirectiveIndex(0, 1),
|
||||||
callOnChange: true,
|
callOnChanges: true,
|
||||||
callOnCheck: true,
|
callDoCheck: true,
|
||||||
callOnAllChangesDone: true
|
callAfterContentChecked: true
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
static recordNoCallbacks = new DirectiveRecord({
|
static recordNoCallbacks = new DirectiveRecord({
|
||||||
directiveIndex: new DirectiveIndex(0, 0),
|
directiveIndex: new DirectiveIndex(0, 0),
|
||||||
callOnChange: false,
|
callOnChanges: false,
|
||||||
callOnCheck: false,
|
callDoCheck: false,
|
||||||
callOnAllChangesDone: false
|
callAfterContentChecked: false
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,13 +315,13 @@ class _DirectiveUpdating {
|
||||||
[
|
[
|
||||||
_DirectiveUpdating.updateA('1', _DirectiveUpdating.basicRecords[0]),
|
_DirectiveUpdating.updateA('1', _DirectiveUpdating.basicRecords[0]),
|
||||||
_DirectiveUpdating.updateB('2', _DirectiveUpdating.basicRecords[0]),
|
_DirectiveUpdating.updateB('2', _DirectiveUpdating.basicRecords[0]),
|
||||||
BindingRecord.createDirectiveOnChange(_DirectiveUpdating.basicRecords[0]),
|
BindingRecord.createDirectiveOnChanges(_DirectiveUpdating.basicRecords[0]),
|
||||||
_DirectiveUpdating.updateA('3', _DirectiveUpdating.basicRecords[1]),
|
_DirectiveUpdating.updateA('3', _DirectiveUpdating.basicRecords[1]),
|
||||||
BindingRecord.createDirectiveOnChange(_DirectiveUpdating.basicRecords[1])
|
BindingRecord.createDirectiveOnChanges(_DirectiveUpdating.basicRecords[1])
|
||||||
],
|
],
|
||||||
[_DirectiveUpdating.basicRecords[0], _DirectiveUpdating.basicRecords[1]]),
|
[_DirectiveUpdating.basicRecords[0], _DirectiveUpdating.basicRecords[1]]),
|
||||||
'directiveOnCheck': new _DirectiveUpdating(
|
'directiveDoCheck': new _DirectiveUpdating(
|
||||||
[BindingRecord.createDirectiveOnCheck(_DirectiveUpdating.basicRecords[0])],
|
[BindingRecord.createDirectiveDoCheck(_DirectiveUpdating.basicRecords[0])],
|
||||||
[_DirectiveUpdating.basicRecords[0]]),
|
[_DirectiveUpdating.basicRecords[0]]),
|
||||||
'directiveOnInit': new _DirectiveUpdating(
|
'directiveOnInit': new _DirectiveUpdating(
|
||||||
[BindingRecord.createDirectiveOnInit(_DirectiveUpdating.basicRecords[0])],
|
[BindingRecord.createDirectiveOnInit(_DirectiveUpdating.basicRecords[0])],
|
||||||
|
|
|
@ -364,7 +364,7 @@ export function main() {
|
||||||
it('should notify the dispatcher on all changes done', () => {
|
it('should notify the dispatcher on all changes done', () => {
|
||||||
var val = _createChangeDetector('name', new Person('bob'));
|
var val = _createChangeDetector('name', new Person('bob'));
|
||||||
val.changeDetector.detectChanges();
|
val.changeDetector.detectChanges();
|
||||||
expect(val.dispatcher.onAllChangesDoneCalled).toEqual(true);
|
expect(val.dispatcher.afterContentCheckedCalled).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('updating directives', () => {
|
describe('updating directives', () => {
|
||||||
|
@ -385,7 +385,7 @@ export function main() {
|
||||||
expect(directive1.a).toEqual(42);
|
expect(directive1.a).toEqual(42);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onChange', () => {
|
describe('onChanges', () => {
|
||||||
it('should notify the directive when a group of records changes', () => {
|
it('should notify the directive when a group of records changes', () => {
|
||||||
var cd = _createWithoutHydrate('groupChanges').changeDetector;
|
var cd = _createWithoutHydrate('groupChanges').changeDetector;
|
||||||
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1, directive2], []),
|
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1, directive2], []),
|
||||||
|
@ -396,28 +396,28 @@ export function main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onCheck', () => {
|
describe('doCheck', () => {
|
||||||
it('should notify the directive when it is checked', () => {
|
it('should notify the directive when it is checked', () => {
|
||||||
var cd = _createWithoutHydrate('directiveOnCheck').changeDetector;
|
var cd = _createWithoutHydrate('directiveDoCheck').changeDetector;
|
||||||
|
|
||||||
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1], []), null);
|
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1], []), null);
|
||||||
cd.detectChanges();
|
cd.detectChanges();
|
||||||
|
|
||||||
expect(directive1.onCheckCalled).toBe(true);
|
expect(directive1.doCheckCalled).toBe(true);
|
||||||
directive1.onCheckCalled = false;
|
directive1.doCheckCalled = false;
|
||||||
|
|
||||||
cd.detectChanges();
|
cd.detectChanges();
|
||||||
expect(directive1.onCheckCalled).toBe(true);
|
expect(directive1.doCheckCalled).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not call onCheck in detectNoChanges', () => {
|
it('should not call doCheck in detectNoChanges', () => {
|
||||||
var cd = _createWithoutHydrate('directiveOnCheck').changeDetector;
|
var cd = _createWithoutHydrate('directiveDoCheck').changeDetector;
|
||||||
|
|
||||||
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1], []), null);
|
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1], []), null);
|
||||||
|
|
||||||
cd.checkNoChanges();
|
cd.checkNoChanges();
|
||||||
|
|
||||||
expect(directive1.onCheckCalled).toBe(false);
|
expect(directive1.doCheckCalled).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onAllChangesDone', () => {
|
describe('afterContentChecked', () => {
|
||||||
it('should be called after processing all the children', () => {
|
it('should be called after processing all the children', () => {
|
||||||
var cd = _createWithoutHydrate('emptyWithDirectiveRecords').changeDetector;
|
var cd = _createWithoutHydrate('emptyWithDirectiveRecords').changeDetector;
|
||||||
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1, directive2], []),
|
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1, directive2], []),
|
||||||
|
@ -457,35 +457,35 @@ export function main() {
|
||||||
|
|
||||||
cd.detectChanges();
|
cd.detectChanges();
|
||||||
|
|
||||||
expect(directive1.onChangesDoneCalled).toBe(true);
|
expect(directive1.afterContentCheckedCalled).toBe(true);
|
||||||
expect(directive2.onChangesDoneCalled).toBe(true);
|
expect(directive2.afterContentCheckedCalled).toBe(true);
|
||||||
|
|
||||||
// reset directives
|
// reset directives
|
||||||
directive1.onChangesDoneCalled = false;
|
directive1.afterContentCheckedCalled = false;
|
||||||
directive2.onChangesDoneCalled = false;
|
directive2.afterContentCheckedCalled = false;
|
||||||
|
|
||||||
// Verify that checking should not call them.
|
// Verify that checking should not call them.
|
||||||
cd.checkNoChanges();
|
cd.checkNoChanges();
|
||||||
|
|
||||||
expect(directive1.onChangesDoneCalled).toBe(false);
|
expect(directive1.afterContentCheckedCalled).toBe(false);
|
||||||
expect(directive2.onChangesDoneCalled).toBe(false);
|
expect(directive2.afterContentCheckedCalled).toBe(false);
|
||||||
|
|
||||||
// re-verify that changes are still detected
|
// re-verify that changes are still detected
|
||||||
cd.detectChanges();
|
cd.detectChanges();
|
||||||
|
|
||||||
expect(directive1.onChangesDoneCalled).toBe(true);
|
expect(directive1.afterContentCheckedCalled).toBe(true);
|
||||||
expect(directive2.onChangesDoneCalled).toBe(true);
|
expect(directive2.afterContentCheckedCalled).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should not be called when onAllChangesDone is false', () => {
|
it('should not be called when afterContentChecked is false', () => {
|
||||||
var cd = _createWithoutHydrate('noCallbacks').changeDetector;
|
var cd = _createWithoutHydrate('noCallbacks').changeDetector;
|
||||||
|
|
||||||
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1], []), null);
|
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1], []), null);
|
||||||
|
|
||||||
cd.detectChanges();
|
cd.detectChanges();
|
||||||
|
|
||||||
expect(directive1.onChangesDoneCalled).toEqual(false);
|
expect(directive1.afterContentCheckedCalled).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be called in reverse order so the child is always notified before the parent',
|
it('should be called in reverse order so the child is always notified before the parent',
|
||||||
|
@ -1104,17 +1104,17 @@ class TestDirective {
|
||||||
a;
|
a;
|
||||||
b;
|
b;
|
||||||
changes;
|
changes;
|
||||||
onChangesDoneCalled;
|
afterContentCheckedCalled;
|
||||||
onChangesDoneSpy;
|
afterContentCheckedSpy;
|
||||||
onCheckCalled;
|
doCheckCalled;
|
||||||
onInitCalled;
|
onInitCalled;
|
||||||
event;
|
event;
|
||||||
|
|
||||||
constructor(onChangesDoneSpy = null) {
|
constructor(onChangesDoneSpy = null) {
|
||||||
this.onChangesDoneCalled = false;
|
this.afterContentCheckedCalled = false;
|
||||||
this.onCheckCalled = false;
|
this.doCheckCalled = false;
|
||||||
this.onInitCalled = false;
|
this.onInitCalled = false;
|
||||||
this.onChangesDoneSpy = onChangesDoneSpy;
|
this.afterContentCheckedSpy = onChangesDoneSpy;
|
||||||
this.a = null;
|
this.a = null;
|
||||||
this.b = null;
|
this.b = null;
|
||||||
this.changes = null;
|
this.changes = null;
|
||||||
|
@ -1122,20 +1122,20 @@ class TestDirective {
|
||||||
|
|
||||||
onEvent(event) { this.event = event; }
|
onEvent(event) { this.event = event; }
|
||||||
|
|
||||||
onCheck() { this.onCheckCalled = true; }
|
doCheck() { this.doCheckCalled = true; }
|
||||||
|
|
||||||
onInit() { this.onInitCalled = true; }
|
onInit() { this.onInitCalled = true; }
|
||||||
|
|
||||||
onChange(changes) {
|
onChanges(changes) {
|
||||||
var r = {};
|
var r = {};
|
||||||
StringMapWrapper.forEach(changes, (c, key) => r[key] = c.currentValue);
|
StringMapWrapper.forEach(changes, (c, key) => r[key] = c.currentValue);
|
||||||
this.changes = r;
|
this.changes = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
onAllChangesDone() {
|
afterContentChecked() {
|
||||||
this.onChangesDoneCalled = true;
|
this.afterContentCheckedCalled = true;
|
||||||
if (isPresent(this.onChangesDoneSpy)) {
|
if (isPresent(this.afterContentCheckedSpy)) {
|
||||||
this.onChangesDoneSpy();
|
this.afterContentCheckedSpy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1182,7 +1182,7 @@ class TestDispatcher implements ChangeDispatcher {
|
||||||
log: string[];
|
log: string[];
|
||||||
debugLog: string[];
|
debugLog: string[];
|
||||||
loggedValues: List<any>;
|
loggedValues: List<any>;
|
||||||
onAllChangesDoneCalled: boolean = false;
|
afterContentCheckedCalled: boolean = false;
|
||||||
|
|
||||||
constructor() { this.clear(); }
|
constructor() { this.clear(); }
|
||||||
|
|
||||||
|
@ -1190,7 +1190,7 @@ class TestDispatcher implements ChangeDispatcher {
|
||||||
this.log = [];
|
this.log = [];
|
||||||
this.debugLog = [];
|
this.debugLog = [];
|
||||||
this.loggedValues = [];
|
this.loggedValues = [];
|
||||||
this.onAllChangesDoneCalled = true;
|
this.afterContentCheckedCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyOnBinding(target, value) {
|
notifyOnBinding(target, value) {
|
||||||
|
@ -1200,7 +1200,7 @@ class TestDispatcher implements ChangeDispatcher {
|
||||||
|
|
||||||
logBindingUpdate(target, value) { this.debugLog.push(`${target.name}=${this._asString(value)}`); }
|
logBindingUpdate(target, value) { this.debugLog.push(`${target.name}=${this._asString(value)}`); }
|
||||||
|
|
||||||
notifyOnAllChangesDone() { this.onAllChangesDoneCalled = true; }
|
notifyAfterContentChecked() { this.afterContentCheckedCalled = true; }
|
||||||
|
|
||||||
getDebugContext(a, b) { return null; }
|
getDebugContext(a, b) { return null; }
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ export function main() {
|
||||||
|
|
||||||
it("should not coalesce directive lifecycle records", () => {
|
it("should not coalesce directive lifecycle records", () => {
|
||||||
var rs = coalesce([
|
var rs = coalesce([
|
||||||
r("onCheck", [], 0, 1, {mode: RecordType.DirectiveLifecycle}),
|
r("doCheck", [], 0, 1, {mode: RecordType.DirectiveLifecycle}),
|
||||||
r("onCheck", [], 0, 1, {mode: RecordType.DirectiveLifecycle})
|
r("doCheck", [], 0, 1, {mode: RecordType.DirectiveLifecycle})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(rs.length).toEqual(2);
|
expect(rs.length).toEqual(2);
|
||||||
|
|
|
@ -10,27 +10,27 @@ main() {
|
||||||
metadata(type, annotation) =>
|
metadata(type, annotation) =>
|
||||||
DirectiveBinding.createFromType(type, annotation).metadata;
|
DirectiveBinding.createFromType(type, annotation).metadata;
|
||||||
|
|
||||||
describe("onChange", () {
|
describe("onChanges", () {
|
||||||
it("should be true when the directive implements OnChange", () {
|
it("should be true when the directive implements OnChanges", () {
|
||||||
expect(metadata(DirectiveImplementingOnChange, new Directive())
|
expect(metadata(DirectiveImplementingOnChanges, new Directive())
|
||||||
.callOnChange).toBe(true);
|
.callOnChanges).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onChange", () {
|
it("should be true when the lifecycle includes onChanges", () {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new Directive(lifecycle: [LifecycleEvent.onChange]))
|
new Directive(lifecycle: [LifecycleEvent.OnChanges]))
|
||||||
.callOnChange).toBe(true);
|
.callOnChanges).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () {
|
it("should be false otherwise", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnChange)
|
expect(metadata(DirectiveNoHooks, new Directive()).callOnChanges)
|
||||||
.toBe(false);
|
.toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false when empty lifecycle", () {
|
it("should be false when empty lifecycle", () {
|
||||||
expect(metadata(
|
expect(metadata(
|
||||||
DirectiveImplementingOnChange, new Directive(lifecycle: []))
|
DirectiveImplementingOnChanges, new Directive(lifecycle: []))
|
||||||
.callOnChange).toBe(false);
|
.callOnChanges).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ main() {
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onDestroy", () {
|
it("should be true when the lifecycle includes onDestroy", () {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new Directive(lifecycle: [LifecycleEvent.onDestroy]))
|
new Directive(lifecycle: [LifecycleEvent.OnDestroy]))
|
||||||
.callOnDestroy).toBe(true);
|
.callOnDestroy).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -52,20 +52,20 @@ main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onCheck", () {
|
describe("doCheck", () {
|
||||||
it("should be true when the directive implements OnCheck", () {
|
it("should be true when the directive implements DoCheck", () {
|
||||||
expect(metadata(DirectiveImplementingOnCheck, new Directive())
|
expect(metadata(DirectiveImplementingOnCheck, new Directive())
|
||||||
.callOnCheck).toBe(true);
|
.callDoCheck).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onCheck", () {
|
it("should be true when the lifecycle includes doCheck", () {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new Directive(lifecycle: [LifecycleEvent.onCheck]))
|
new Directive(lifecycle: [LifecycleEvent.DoCheck]))
|
||||||
.callOnCheck).toBe(true);
|
.callDoCheck).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () {
|
it("should be false otherwise", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnCheck)
|
expect(metadata(DirectiveNoHooks, new Directive()).callDoCheck)
|
||||||
.toBe(false);
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -78,7 +78,7 @@ main() {
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onInit", () {
|
it("should be true when the lifecycle includes onInit", () {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new Directive(lifecycle: [LifecycleEvent.onInit])).callOnInit)
|
new Directive(lifecycle: [LifecycleEvent.OnInit])).callOnInit)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -88,22 +88,22 @@ main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onAllChangesDone", () {
|
describe("afterContentChecked", () {
|
||||||
it("should be true when the directive implements OnAllChangesDone", () {
|
it("should be true when the directive implements AfterContentChecked", () {
|
||||||
expect(
|
expect(
|
||||||
metadata(DirectiveImplementingOnAllChangesDone, new Directive())
|
metadata(DirectiveImplementingAfterContentChecked, new Directive())
|
||||||
.callOnAllChangesDone).toBe(true);
|
.callAfterContentChecked).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onAllChangesDone", () {
|
it("should be true when the lifecycle includes afterContentChecked", () {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new Directive(lifecycle: [LifecycleEvent.onAllChangesDone]))
|
new Directive(lifecycle: [LifecycleEvent.AfterContentChecked]))
|
||||||
.callOnAllChangesDone).toBe(true);
|
.callAfterContentChecked).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () {
|
it("should be false otherwise", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive())
|
expect(metadata(DirectiveNoHooks, new Directive())
|
||||||
.callOnAllChangesDone).toBe(false);
|
.callAfterContentChecked).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -112,12 +112,12 @@ main() {
|
||||||
|
|
||||||
class DirectiveNoHooks {}
|
class DirectiveNoHooks {}
|
||||||
|
|
||||||
class DirectiveImplementingOnChange implements OnChange {
|
class DirectiveImplementingOnChanges implements OnChanges {
|
||||||
onChange(_) {}
|
onChanges(_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveImplementingOnCheck implements OnCheck {
|
class DirectiveImplementingOnCheck implements DoCheck {
|
||||||
onCheck() {}
|
doCheck() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveImplementingOnInit implements OnInit {
|
class DirectiveImplementingOnInit implements OnInit {
|
||||||
|
@ -128,6 +128,6 @@ class DirectiveImplementingOnDestroy implements OnDestroy {
|
||||||
onDestroy() {}
|
onDestroy() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveImplementingOnAllChangesDone implements OnAllChangesDone {
|
class DirectiveImplementingAfterContentChecked implements AfterContentChecked {
|
||||||
onAllChangesDone() {}
|
afterContentChecked() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,34 +15,35 @@ import {
|
||||||
|
|
||||||
import {DirectiveMetadata, LifecycleEvent} from 'angular2/src/core/metadata';
|
import {DirectiveMetadata, LifecycleEvent} from 'angular2/src/core/metadata';
|
||||||
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
||||||
|
import {RenderDirectiveMetadata} from 'angular2/src/core/render/api';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('Create DirectiveMetadata', () => {
|
describe('Create DirectiveMetadata', () => {
|
||||||
describe('lifecycle', () => {
|
describe('lifecycle', () => {
|
||||||
function metadata(type, annotation) {
|
function metadata(type, annotation): RenderDirectiveMetadata {
|
||||||
return DirectiveBinding.createFromType(type, annotation).metadata;
|
return DirectiveBinding.createFromType(type, annotation).metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("onChange", () => {
|
describe("onChanges", () => {
|
||||||
it("should be true when the directive has the onChange method", () => {
|
it("should be true when the directive has the onChanges method", () => {
|
||||||
expect(metadata(DirectiveWithOnChangeMethod, new DirectiveMetadata({})).callOnChange)
|
expect(metadata(DirectiveWithOnChangesMethod, new DirectiveMetadata({})).callOnChanges)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onChange", () => {
|
it("should be true when the lifecycle includes onChanges", () => {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new DirectiveMetadata({lifecycle: [LifecycleEvent.onChange]}))
|
new DirectiveMetadata({lifecycle: [LifecycleEvent.OnChanges]}))
|
||||||
.callOnChange)
|
.callOnChanges)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () => {
|
it("should be false otherwise", () => {
|
||||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnChange).toBe(false);
|
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnChanges).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false when empty lifecycle", () => {
|
it("should be false when empty lifecycle", () => {
|
||||||
expect(metadata(DirectiveWithOnChangeMethod, new DirectiveMetadata({lifecycle: []}))
|
expect(metadata(DirectiveWithOnChangesMethod, new DirectiveMetadata({lifecycle: []}))
|
||||||
.callOnChange)
|
.callOnChanges)
|
||||||
.toBe(false);
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -55,7 +56,7 @@ export function main() {
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onDestroy", () => {
|
it("should be true when the lifecycle includes onDestroy", () => {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new DirectiveMetadata({lifecycle: [LifecycleEvent.onDestroy]}))
|
new DirectiveMetadata({lifecycle: [LifecycleEvent.OnDestroy]}))
|
||||||
.callOnDestroy)
|
.callOnDestroy)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
@ -73,7 +74,7 @@ export function main() {
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onDestroy", () => {
|
it("should be true when the lifecycle includes onDestroy", () => {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new DirectiveMetadata({lifecycle: [LifecycleEvent.onInit]}))
|
new DirectiveMetadata({lifecycle: [LifecycleEvent.OnInit]}))
|
||||||
.callOnInit)
|
.callOnInit)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
@ -83,40 +84,40 @@ export function main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onCheck", () => {
|
describe("doCheck", () => {
|
||||||
it("should be true when the directive has the onCheck method", () => {
|
it("should be true when the directive has the doCheck method", () => {
|
||||||
expect(metadata(DirectiveWithOnCheckMethod, new DirectiveMetadata({})).callOnCheck)
|
expect(metadata(DirectiveWithOnCheckMethod, new DirectiveMetadata({})).callDoCheck)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onCheck", () => {
|
it("should be true when the lifecycle includes doCheck", () => {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new DirectiveMetadata({lifecycle: [LifecycleEvent.onCheck]}))
|
new DirectiveMetadata({lifecycle: [LifecycleEvent.DoCheck]}))
|
||||||
.callOnCheck)
|
.callDoCheck)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () => {
|
it("should be false otherwise", () => {
|
||||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnCheck).toBe(false);
|
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callDoCheck).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onAllChangesDone", () => {
|
describe("afterContentChecked", () => {
|
||||||
it("should be true when the directive has the onAllChangesDone method", () => {
|
it("should be true when the directive has the afterContentChecked method", () => {
|
||||||
expect(metadata(DirectiveWithOnAllChangesDoneMethod, new DirectiveMetadata({}))
|
expect(metadata(DirectiveWithAfterContentCheckedMethod, new DirectiveMetadata({}))
|
||||||
.callOnAllChangesDone)
|
.callAfterContentChecked)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onAllChangesDone", () => {
|
it("should be true when the lifecycle includes afterContentChecked", () => {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new DirectiveMetadata({lifecycle: [LifecycleEvent.onAllChangesDone]}))
|
new DirectiveMetadata({lifecycle: [LifecycleEvent.AfterContentChecked]}))
|
||||||
.callOnAllChangesDone)
|
.callAfterContentChecked)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () => {
|
it("should be false otherwise", () => {
|
||||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnAllChangesDone)
|
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callAfterContentChecked)
|
||||||
.toBe(false);
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -126,8 +127,8 @@ export function main() {
|
||||||
|
|
||||||
class DirectiveNoHooks {}
|
class DirectiveNoHooks {}
|
||||||
|
|
||||||
class DirectiveWithOnChangeMethod {
|
class DirectiveWithOnChangesMethod {
|
||||||
onChange(_) {}
|
onChanges(_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveWithOnInitMethod {
|
class DirectiveWithOnInitMethod {
|
||||||
|
@ -135,13 +136,13 @@ class DirectiveWithOnInitMethod {
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveWithOnCheckMethod {
|
class DirectiveWithOnCheckMethod {
|
||||||
onCheck() {}
|
doCheck() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveWithOnDestroyMethod {
|
class DirectiveWithOnDestroyMethod {
|
||||||
onDestroy(_) {}
|
onDestroy(_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveWithOnAllChangesDoneMethod {
|
class DirectiveWithAfterContentCheckedMethod {
|
||||||
onAllChangesDone() {}
|
afterContentChecked() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,7 +265,7 @@ class DynamicallyCreatedComponentService {}
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'hello-cmp',
|
selector: 'hello-cmp',
|
||||||
viewBindings: [DynamicallyCreatedComponentService],
|
viewBindings: [DynamicallyCreatedComponentService],
|
||||||
lifecycle: [LifecycleEvent.onDestroy]
|
lifecycle: [LifecycleEvent.OnDestroy]
|
||||||
})
|
})
|
||||||
@View({template: "{{greeting}}"})
|
@View({template: "{{greeting}}"})
|
||||||
class DynamicallyCreatedCmp {
|
class DynamicallyCreatedCmp {
|
||||||
|
|
|
@ -871,7 +871,7 @@ export function main() {
|
||||||
it("should call onDestroy on directives subscribed to this event", () => {
|
it("should call onDestroy on directives subscribed to this event", () => {
|
||||||
var inj = injector(ListWrapper.concat(
|
var inj = injector(ListWrapper.concat(
|
||||||
[DirectiveBinding.createFromType(DirectiveWithDestroy,
|
[DirectiveBinding.createFromType(DirectiveWithDestroy,
|
||||||
new DirectiveMetadata({lifecycle: [LifecycleEvent.onDestroy]}))],
|
new DirectiveMetadata({lifecycle: [LifecycleEvent.OnDestroy]}))],
|
||||||
extraBindings));
|
extraBindings));
|
||||||
var destroy = inj.get(DirectiveWithDestroy);
|
var destroy = inj.get(DirectiveWithDestroy);
|
||||||
inj.dehydrate();
|
inj.dehydrate();
|
||||||
|
@ -893,7 +893,7 @@ export function main() {
|
||||||
|
|
||||||
query.onChange(() => async.done());
|
query.onChange(() => async.done());
|
||||||
|
|
||||||
inj.onAllChangesDone();
|
inj.afterContentChecked();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it("should not notify inherited queries", inject([AsyncTestCompleter], (async) => {
|
it("should not notify inherited queries", inject([AsyncTestCompleter], (async) => {
|
||||||
|
@ -912,10 +912,10 @@ export function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
query.add(new CountingDirective());
|
query.add(new CountingDirective());
|
||||||
child.onAllChangesDone(); // this does not notify the query
|
child.afterContentChecked(); // this does not notify the query
|
||||||
|
|
||||||
query.add(new CountingDirective());
|
query.add(new CountingDirective());
|
||||||
child.parent.onAllChangesDone();
|
child.parent.afterContentChecked();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -267,15 +267,15 @@ class NoPropertyAccess {
|
||||||
@Component(
|
@Component(
|
||||||
selector: 'on-change',
|
selector: 'on-change',
|
||||||
// TODO: needed because of https://github.com/angular/angular/issues/2120
|
// TODO: needed because of https://github.com/angular/angular/issues/2120
|
||||||
lifecycle: const [LifecycleEvent.onChange],
|
lifecycle: const [LifecycleEvent.OnChanges],
|
||||||
properties: const ['prop'])
|
properties: const ['prop'])
|
||||||
@View(template: '')
|
@View(template: '')
|
||||||
class OnChangeComponent implements OnChange {
|
class OnChangeComponent implements OnChanges {
|
||||||
Map changes;
|
Map changes;
|
||||||
String prop;
|
String prop;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onChange(Map changes) {
|
void onChanges(Map changes) {
|
||||||
this.changes = changes;
|
this.changes = changes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,11 +301,11 @@ class ComponentWithObservableList {
|
||||||
|
|
||||||
@Directive(
|
@Directive(
|
||||||
selector: 'directive-logging-checks',
|
selector: 'directive-logging-checks',
|
||||||
lifecycle: const [LifecycleEvent.onCheck])
|
lifecycle: const [LifecycleEvent.DoCheck])
|
||||||
class DirectiveLoggingChecks implements OnCheck {
|
class DirectiveLoggingChecks implements DoCheck {
|
||||||
Log log;
|
Log log;
|
||||||
|
|
||||||
DirectiveLoggingChecks(this.log);
|
DirectiveLoggingChecks(this.log);
|
||||||
|
|
||||||
onCheck() => log.add("check");
|
doCheck() => log.add("check");
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,7 +489,7 @@ class InertDirective {
|
||||||
@Component({selector: 'needs-query'})
|
@Component({selector: 'needs-query'})
|
||||||
@View({
|
@View({
|
||||||
directives: [NgFor, TextDirective],
|
directives: [NgFor, TextDirective],
|
||||||
template: '<div text="ignoreme"></div><div *ng-for="var dir of query">{{dir.text}}|</div>'
|
template: '<div text="ignoreme"></div><b *ng-for="var dir of query">{{dir.text}}|</b>'
|
||||||
})
|
})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class NeedsQuery {
|
class NeedsQuery {
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {Directive, Component, View, ViewMetadata, LifecycleEvent} from 'angular2
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('directive lifecycle integration spec', () => {
|
describe('directive lifecycle integration spec', () => {
|
||||||
|
|
||||||
it('should invoke lifecycle methods onChange > onInit > onCheck > onAllChangesDone',
|
it('should invoke lifecycle methods onChanges > onInit > doCheck > afterContentChecked',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
|
@ -28,17 +28,17 @@ export function main() {
|
||||||
var dir = tc.componentViewChildren[0].inject(LifecycleDir);
|
var dir = tc.componentViewChildren[0].inject(LifecycleDir);
|
||||||
tc.detectChanges();
|
tc.detectChanges();
|
||||||
|
|
||||||
expect(dir.log).toEqual(["onChange", "onInit", "onCheck", "onAllChangesDone"]);
|
expect(dir.log).toEqual(["onChanges", "onInit", "doCheck", "afterContentChecked"]);
|
||||||
|
|
||||||
tc.detectChanges();
|
tc.detectChanges();
|
||||||
|
|
||||||
expect(dir.log).toEqual([
|
expect(dir.log).toEqual([
|
||||||
"onChange",
|
"onChanges",
|
||||||
"onInit",
|
"onInit",
|
||||||
"onCheck",
|
"doCheck",
|
||||||
"onAllChangesDone",
|
"afterContentChecked",
|
||||||
"onCheck",
|
"doCheck",
|
||||||
"onAllChangesDone"
|
"afterContentChecked"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
async.done();
|
async.done();
|
||||||
|
@ -52,10 +52,10 @@ export function main() {
|
||||||
selector: "[lifecycle]",
|
selector: "[lifecycle]",
|
||||||
properties: ['field'],
|
properties: ['field'],
|
||||||
lifecycle: [
|
lifecycle: [
|
||||||
LifecycleEvent.onChange,
|
LifecycleEvent.OnChanges,
|
||||||
LifecycleEvent.onCheck,
|
LifecycleEvent.DoCheck,
|
||||||
LifecycleEvent.onInit,
|
LifecycleEvent.OnInit,
|
||||||
LifecycleEvent.onAllChangesDone
|
LifecycleEvent.AfterContentChecked
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
class LifecycleDir {
|
class LifecycleDir {
|
||||||
|
@ -64,13 +64,13 @@ class LifecycleDir {
|
||||||
|
|
||||||
constructor() { this.log = []; }
|
constructor() { this.log = []; }
|
||||||
|
|
||||||
onChange(_) { this.log.push("onChange"); }
|
onChanges(_) { this.log.push("onChanges"); }
|
||||||
|
|
||||||
onInit() { this.log.push("onInit"); }
|
onInit() { this.log.push("onInit"); }
|
||||||
|
|
||||||
onCheck() { this.log.push("onCheck"); }
|
doCheck() { this.log.push("doCheck"); }
|
||||||
|
|
||||||
onAllChangesDone() { this.log.push("onAllChangesDone"); }
|
afterContentChecked() { this.log.push("afterContentChecked"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'my-comp'})
|
@Component({selector: 'my-comp'})
|
||||||
|
|
|
@ -117,13 +117,13 @@ export function main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onChange", () => {
|
describe("onChanges", () => {
|
||||||
it("should update dom values of all the directives", () => {
|
it("should update dom values of all the directives", () => {
|
||||||
form.addControl(loginControlDir);
|
form.addControl(loginControlDir);
|
||||||
|
|
||||||
formModel.find(["login"]).updateValue("new value");
|
formModel.find(["login"]).updateValue("new value");
|
||||||
|
|
||||||
form.onChange(null);
|
form.onChanges(null);
|
||||||
|
|
||||||
expect((<any>loginControlDir.valueAccessor).writtenValue).toEqual("new value");
|
expect((<any>loginControlDir.valueAccessor).writtenValue).toEqual("new value");
|
||||||
});
|
});
|
||||||
|
@ -244,7 +244,7 @@ export function main() {
|
||||||
expect(control.valid).toBe(true);
|
expect(control.valid).toBe(true);
|
||||||
|
|
||||||
// this will add the required validator and recalculate the validity
|
// this will add the required validator and recalculate the validity
|
||||||
controlDir.onChange({});
|
controlDir.onChanges({});
|
||||||
|
|
||||||
expect(control.valid).toBe(false);
|
expect(control.valid).toBe(false);
|
||||||
});
|
});
|
||||||
|
@ -276,7 +276,7 @@ export function main() {
|
||||||
expect(ngModel.control.valid).toBe(true);
|
expect(ngModel.control.valid).toBe(true);
|
||||||
|
|
||||||
// this will add the required validator and recalculate the validity
|
// this will add the required validator and recalculate the validity
|
||||||
ngModel.onChange({});
|
ngModel.onChanges({});
|
||||||
|
|
||||||
expect(ngModel.control.valid).toBe(false);
|
expect(ngModel.control.valid).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -68,13 +68,13 @@ export function main() {
|
||||||
expect(c.value).toEqual("newValue");
|
expect(c.value).toEqual("newValue");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should invoke onChange if it is present", () => {
|
it("should invoke onChanges if it is present", () => {
|
||||||
var onChange;
|
var onChanges;
|
||||||
c.registerOnChange((v) => onChange = ["invoked", v]);
|
c.registerOnChange((v) => onChanges = ["invoked", v]);
|
||||||
|
|
||||||
c.updateValue("newValue");
|
c.updateValue("newValue");
|
||||||
|
|
||||||
expect(onChange).toEqual(["invoked", "newValue"]);
|
expect(onChanges).toEqual(["invoked", "newValue"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not invoke on change when explicitly specified", () => {
|
it("should not invoke on change when explicitly specified", () => {
|
||||||
|
|
|
@ -48,7 +48,7 @@ export class MdButton {
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'a[md-button], a[md-raised-button], a[md-fab]',
|
selector: 'a[md-button], a[md-raised-button], a[md-fab]',
|
||||||
properties: ['disabled'],
|
properties: ['disabled'],
|
||||||
lifecycle: [LifecycleEvent.onChange],
|
lifecycle: [LifecycleEvent.OnChanges],
|
||||||
host: {
|
host: {
|
||||||
'(^click)': 'onClick($event)',
|
'(^click)': 'onClick($event)',
|
||||||
'(^mousedown)': 'onMousedown()',
|
'(^mousedown)': 'onMousedown()',
|
||||||
|
@ -86,7 +86,7 @@ export class MdAnchor extends MdButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Invoked when a change is detected. */
|
/** Invoked when a change is detected. */
|
||||||
onChange(_) {
|
onChanges(_) {
|
||||||
// A disabled anchor should not be in the tab flow.
|
// A disabled anchor should not be in the tab flow.
|
||||||
this.tabIndex = this.disabled ? -1 : 0;
|
this.tabIndex = this.disabled ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class RowHeightMode {
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'md-grid-list',
|
selector: 'md-grid-list',
|
||||||
properties: ['cols', 'rowHeight', 'gutterSize'],
|
properties: ['cols', 'rowHeight', 'gutterSize'],
|
||||||
lifecycle: [LifecycleEvent.onAllChangesDone]
|
lifecycle: [LifecycleEvent.AfterContentChecked]
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/grid_list/grid_list.html',
|
templateUrl: 'package:angular2_material/src/components/grid_list/grid_list.html',
|
||||||
|
@ -88,7 +88,7 @@ export class MdGridList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onAllChangesDone() {
|
afterContentChecked() {
|
||||||
this.layoutTiles();
|
this.layoutTiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ export class MdGridList {
|
||||||
'[style.marginTop]': 'style.marginTop',
|
'[style.marginTop]': 'style.marginTop',
|
||||||
'[style.paddingTop]': 'style.paddingTop',
|
'[style.paddingTop]': 'style.paddingTop',
|
||||||
},
|
},
|
||||||
lifecycle: [LifecycleEvent.onDestroy, LifecycleEvent.onChange]
|
lifecycle: [LifecycleEvent.OnDestroy, LifecycleEvent.OnChanges]
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'package:angular2_material/src/components/grid_list/grid_tile.html',
|
templateUrl: 'package:angular2_material/src/components/grid_list/grid_tile.html',
|
||||||
|
@ -269,7 +269,7 @@ export class MdGridTile {
|
||||||
* Change handler invoked when bindings are resolved or when bindings have changed.
|
* Change handler invoked when bindings are resolved or when bindings have changed.
|
||||||
* Notifies grid-list that a re-layout is required.
|
* Notifies grid-list that a re-layout is required.
|
||||||
*/
|
*/
|
||||||
onChange(_) {
|
onChanges(_) {
|
||||||
if (!this.isRegisteredWithGridList) {
|
if (!this.isRegisteredWithGridList) {
|
||||||
this.gridList.addTile(this);
|
this.gridList.addTile(this);
|
||||||
this.isRegisteredWithGridList = true;
|
this.isRegisteredWithGridList = true;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {ObservableWrapper, EventEmitter} from 'angular2/src/core/facade/async';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: 'md-input-container',
|
selector: 'md-input-container',
|
||||||
lifecycle: [LifecycleEvent.onAllChangesDone],
|
lifecycle: [LifecycleEvent.AfterContentChecked],
|
||||||
host: {
|
host: {
|
||||||
'[class.md-input-has-value]': 'inputHasValue',
|
'[class.md-input-has-value]': 'inputHasValue',
|
||||||
'[class.md-input-focused]': 'inputHasFocus',
|
'[class.md-input-focused]': 'inputHasFocus',
|
||||||
|
@ -31,7 +31,7 @@ export class MdInputContainer {
|
||||||
this.inputHasFocus = false;
|
this.inputHasFocus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onAllChangesDone() {
|
afterContentChecked() {
|
||||||
// Enforce that this directive actually contains a text input.
|
// Enforce that this directive actually contains a text input.
|
||||||
if (this._input == null) {
|
if (this._input == null) {
|
||||||
throw 'No <input> or <textarea> found inside of <md-input-container>';
|
throw 'No <input> or <textarea> found inside of <md-input-container>';
|
||||||
|
|
|
@ -15,7 +15,7 @@ class ProgressMode {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'md-progress-linear',
|
selector: 'md-progress-linear',
|
||||||
lifecycle: [LifecycleEvent.onChange],
|
lifecycle: [LifecycleEvent.OnChanges],
|
||||||
properties: ['value', 'bufferValue'],
|
properties: ['value', 'bufferValue'],
|
||||||
host: {
|
host: {
|
||||||
'role': 'progressbar',
|
'role': 'progressbar',
|
||||||
|
@ -62,7 +62,7 @@ export class MdProgressLinear {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(_) {
|
onChanges(_) {
|
||||||
// If the mode does not use a value, or if there is no value, do nothing.
|
// If the mode does not use a value, or if there is no value, do nothing.
|
||||||
if (this.mode == ProgressMode.QUERY || this.mode == ProgressMode.INDETERMINATE ||
|
if (this.mode == ProgressMode.QUERY || this.mode == ProgressMode.INDETERMINATE ||
|
||||||
isBlank(this.value)) {
|
isBlank(this.value)) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ var _uniqueIdCounter: number = 0;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'md-radio-group',
|
selector: 'md-radio-group',
|
||||||
lifecycle: [LifecycleEvent.onChange],
|
lifecycle: [LifecycleEvent.OnChanges],
|
||||||
events: ['change'],
|
events: ['change'],
|
||||||
properties: ['disabled', 'value'],
|
properties: ['disabled', 'value'],
|
||||||
host: {
|
host: {
|
||||||
|
@ -103,7 +103,7 @@ export class MdRadioGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Change handler invoked when bindings are resolved or when bindings have changed. */
|
/** Change handler invoked when bindings are resolved or when bindings have changed. */
|
||||||
onChange(_) {
|
onChanges(_) {
|
||||||
// If the component has a disabled attribute with no value, it will set disabled = ''.
|
// If the component has a disabled attribute with no value, it will set disabled = ''.
|
||||||
this.disabled = isPresent(this.disabled) && this.disabled !== false;
|
this.disabled = isPresent(this.disabled) && this.disabled !== false;
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ export class MdRadioGroup {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'md-radio-button',
|
selector: 'md-radio-button',
|
||||||
lifecycle: [LifecycleEvent.onInit],
|
lifecycle: [LifecycleEvent.OnInit],
|
||||||
properties: ['id', 'name', 'value', 'checked', 'disabled'],
|
properties: ['id', 'name', 'value', 'checked', 'disabled'],
|
||||||
host: {
|
host: {
|
||||||
'role': 'radio',
|
'role': 'radio',
|
||||||
|
|
|
@ -388,5 +388,5 @@ class DummyDispatcher implements ChangeDispatcher {
|
||||||
}
|
}
|
||||||
notifyOnBinding(bindingTarget, newValue) { throw "Should not be used"; }
|
notifyOnBinding(bindingTarget, newValue) { throw "Should not be used"; }
|
||||||
logBindingUpdate(bindingTarget, newValue) { throw "Should not be used"; }
|
logBindingUpdate(bindingTarget, newValue) { throw "Should not be used"; }
|
||||||
notifyOnAllChangesDone() {}
|
notifyAfterContentChecked() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,10 @@ Map<String, dynamic> directiveMetadataToMap(RenderDirectiveMetadata meta) {
|
||||||
["type", meta.type],
|
["type", meta.type],
|
||||||
["exportAs", meta.exportAs],
|
["exportAs", meta.exportAs],
|
||||||
["callOnDestroy", meta.callOnDestroy],
|
["callOnDestroy", meta.callOnDestroy],
|
||||||
["callOnCheck", meta.callOnCheck],
|
["callDoCheck", meta.callDoCheck],
|
||||||
["callOnInit", meta.callOnInit],
|
["callOnInit", meta.callOnInit],
|
||||||
["callOnChange", meta.callOnChange],
|
["callOnChanges", meta.callOnChanges],
|
||||||
["callOnAllChangesDone", meta.callOnAllChangesDone],
|
["callAfterContentChecked", meta.callAfterContentChecked],
|
||||||
["events", meta.events],
|
["events", meta.events],
|
||||||
["changeDetection", meta.changeDetection == null ? null : meta.changeDetection.index],
|
["changeDetection", meta.changeDetection == null ? null : meta.changeDetection.index],
|
||||||
["version", 1]
|
["version", 1]
|
||||||
|
@ -54,10 +54,10 @@ RenderDirectiveMetadata directiveMetadataFromMap(Map<String, dynamic> map) {
|
||||||
type: (map["type"] as num),
|
type: (map["type"] as num),
|
||||||
exportAs: (map["exportAs"] as String),
|
exportAs: (map["exportAs"] as String),
|
||||||
callOnDestroy: (map["callOnDestroy"] as bool),
|
callOnDestroy: (map["callOnDestroy"] as bool),
|
||||||
callOnCheck: (map["callOnCheck"] as bool),
|
callDoCheck: (map["callDoCheck"] as bool),
|
||||||
callOnChange: (map["callOnChange"] as bool),
|
callOnChanges: (map["callOnChanges"] as bool),
|
||||||
callOnInit: (map["callOnInit"] as bool),
|
callOnInit: (map["callOnInit"] as bool),
|
||||||
callOnAllChangesDone: (map["callOnAllChangesDone"] as bool),
|
callAfterContentChecked: (map["callAfterContentChecked"] as bool),
|
||||||
events: (_cloneIfPresent(map["events"]) as List<String>),
|
events: (_cloneIfPresent(map["events"]) as List<String>),
|
||||||
changeDetection: map["changeDetection"] == null ? null
|
changeDetection: map["changeDetection"] == null ? null
|
||||||
: ChangeDetectionStrategy.values[map["changeDetection"] as int]);
|
: ChangeDetectionStrategy.values[map["changeDetection"] as int]);
|
||||||
|
|
|
@ -63,7 +63,7 @@ class _DirectiveMetadataVisitor extends Object
|
||||||
bool _callOnChange;
|
bool _callOnChange;
|
||||||
bool _callOnCheck;
|
bool _callOnCheck;
|
||||||
bool _callOnInit;
|
bool _callOnInit;
|
||||||
bool _callOnAllChangesDone;
|
bool _callAfterContentChecked;
|
||||||
ChangeDetectionStrategy _changeDetection;
|
ChangeDetectionStrategy _changeDetection;
|
||||||
List<String> _events;
|
List<String> _events;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class _DirectiveMetadataVisitor extends Object
|
||||||
_callOnChange = false;
|
_callOnChange = false;
|
||||||
_callOnCheck = false;
|
_callOnCheck = false;
|
||||||
_callOnInit = false;
|
_callOnInit = false;
|
||||||
_callOnAllChangesDone = false;
|
_callAfterContentChecked = false;
|
||||||
_changeDetection = null;
|
_changeDetection = null;
|
||||||
_events = [];
|
_events = [];
|
||||||
}
|
}
|
||||||
|
@ -97,10 +97,10 @@ class _DirectiveMetadataVisitor extends Object
|
||||||
readAttributes: _readAttributes,
|
readAttributes: _readAttributes,
|
||||||
exportAs: _exportAs,
|
exportAs: _exportAs,
|
||||||
callOnDestroy: _callOnDestroy,
|
callOnDestroy: _callOnDestroy,
|
||||||
callOnChange: _callOnChange,
|
callOnChanges: _callOnChange,
|
||||||
callOnCheck: _callOnCheck,
|
callDoCheck: _callOnCheck,
|
||||||
callOnInit: _callOnInit,
|
callOnInit: _callOnInit,
|
||||||
callOnAllChangesDone: _callOnAllChangesDone,
|
callAfterContentChecked: _callAfterContentChecked,
|
||||||
changeDetection: _changeDetection,
|
changeDetection: _changeDetection,
|
||||||
events: _events);
|
events: _events);
|
||||||
|
|
||||||
|
@ -270,11 +270,11 @@ class _DirectiveMetadataVisitor extends Object
|
||||||
}
|
}
|
||||||
ListLiteral l = lifecycleValue;
|
ListLiteral l = lifecycleValue;
|
||||||
var lifecycleEvents = l.elements.map((s) => s.toSource().split('.').last);
|
var lifecycleEvents = l.elements.map((s) => s.toSource().split('.').last);
|
||||||
_callOnDestroy = lifecycleEvents.contains("onDestroy");
|
_callOnDestroy = lifecycleEvents.contains("OnDestroy");
|
||||||
_callOnChange = lifecycleEvents.contains("onChange");
|
_callOnChange = lifecycleEvents.contains("OnChanges");
|
||||||
_callOnCheck = lifecycleEvents.contains("onCheck");
|
_callOnCheck = lifecycleEvents.contains("DoCheck");
|
||||||
_callOnInit = lifecycleEvents.contains("onInit");
|
_callOnInit = lifecycleEvents.contains("OnInit");
|
||||||
_callOnAllChangesDone = lifecycleEvents.contains("onAllChangesDone");
|
_callAfterContentChecked = lifecycleEvents.contains("AfterContentChecked");
|
||||||
}
|
}
|
||||||
|
|
||||||
void _populateEvents(Expression eventsValue) {
|
void _populateEvents(Expression eventsValue) {
|
||||||
|
|
|
@ -10,10 +10,10 @@ export 'class_matcher_base.dart' show ClassDescriptor;
|
||||||
/// implemented by a class. These classes are re-exported in many places so this
|
/// implemented by a class. These classes are re-exported in many places so this
|
||||||
/// covers all libraries which provide them.
|
/// covers all libraries which provide them.
|
||||||
const _ON_CHANGE_INTERFACES = const [
|
const _ON_CHANGE_INTERFACES = const [
|
||||||
const ClassDescriptor('OnChange', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('OnChanges', 'package:angular2/angular2.dart'),
|
||||||
const ClassDescriptor('OnChange', 'package:angular2/metadata.dart'),
|
const ClassDescriptor('OnChanges', 'package:angular2/metadata.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnChange', 'package:angular2/src/core/compiler/interfaces.dart'),
|
'OnChanges', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||||
];
|
];
|
||||||
const _ON_DESTROY_INTERFACES = const [
|
const _ON_DESTROY_INTERFACES = const [
|
||||||
const ClassDescriptor('OnDestroy', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('OnDestroy', 'package:angular2/angular2.dart'),
|
||||||
|
@ -22,10 +22,10 @@ const _ON_DESTROY_INTERFACES = const [
|
||||||
'OnDestroy', 'package:angular2/src/core/compiler/interfaces.dart'),
|
'OnDestroy', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||||
];
|
];
|
||||||
const _ON_CHECK_INTERFACES = const [
|
const _ON_CHECK_INTERFACES = const [
|
||||||
const ClassDescriptor('OnCheck', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('DoCheck', 'package:angular2/angular2.dart'),
|
||||||
const ClassDescriptor('OnCheck', 'package:angular2/metadata.dart'),
|
const ClassDescriptor('DoCheck', 'package:angular2/metadata.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnCheck', 'package:angular2/src/core/compiler/interfaces.dart'),
|
'DoCheck', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||||
];
|
];
|
||||||
const _ON_INIT_INTERFACES = const [
|
const _ON_INIT_INTERFACES = const [
|
||||||
const ClassDescriptor('OnInit', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('OnInit', 'package:angular2/angular2.dart'),
|
||||||
|
@ -34,11 +34,11 @@ const _ON_INIT_INTERFACES = const [
|
||||||
'OnInit', 'package:angular2/src/core/compiler/interfaces.dart'),
|
'OnInit', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||||
];
|
];
|
||||||
const _ON_ALL_CHANGES_DONE_INTERFACES = const [
|
const _ON_ALL_CHANGES_DONE_INTERFACES = const [
|
||||||
const ClassDescriptor('OnAllChangesDone', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('AfterContentChecked', 'package:angular2/angular2.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnAllChangesDone', 'package:angular2/metadata.dart'),
|
'AfterContentChecked', 'package:angular2/metadata.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnAllChangesDone', 'package:angular2/src/core/compiler/interfaces.dart')
|
'AfterContentChecked', 'package:angular2/src/core/compiler/interfaces.dart')
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Checks if a given [Annotation] matches any of the given
|
/// Checks if a given [Annotation] matches any of the given
|
||||||
|
@ -55,7 +55,7 @@ class InterfaceMatcher extends ClassMatcherBase {
|
||||||
..addAll(_ON_ALL_CHANGES_DONE_INTERFACES));
|
..addAll(_ON_ALL_CHANGES_DONE_INTERFACES));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if an [Identifier] implements [OnChange].
|
/// Checks if an [Identifier] implements [OnChanges].
|
||||||
bool isOnChange(Identifier typeName, AssetId assetId) =>
|
bool isOnChange(Identifier typeName, AssetId assetId) =>
|
||||||
implements(firstMatch(typeName, assetId), _ON_CHANGE_INTERFACES);
|
implements(firstMatch(typeName, assetId), _ON_CHANGE_INTERFACES);
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class InterfaceMatcher extends ClassMatcherBase {
|
||||||
bool isOnDestroy(Identifier typeName, AssetId assetId) =>
|
bool isOnDestroy(Identifier typeName, AssetId assetId) =>
|
||||||
implements(firstMatch(typeName, assetId), _ON_DESTROY_INTERFACES);
|
implements(firstMatch(typeName, assetId), _ON_DESTROY_INTERFACES);
|
||||||
|
|
||||||
/// Checks if an [Identifier] implements [OnCheck].
|
/// Checks if an [Identifier] implements [DoCheck].
|
||||||
bool isOnCheck(Identifier typeName, AssetId assetId) =>
|
bool isOnCheck(Identifier typeName, AssetId assetId) =>
|
||||||
implements(firstMatch(typeName, assetId), _ON_CHECK_INTERFACES);
|
implements(firstMatch(typeName, assetId), _ON_CHECK_INTERFACES);
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class InterfaceMatcher extends ClassMatcherBase {
|
||||||
bool isOnInit(Identifier typeName, AssetId assetId) =>
|
bool isOnInit(Identifier typeName, AssetId assetId) =>
|
||||||
implements(firstMatch(typeName, assetId), _ON_INIT_INTERFACES);
|
implements(firstMatch(typeName, assetId), _ON_INIT_INTERFACES);
|
||||||
|
|
||||||
/// Checks if an [Identifier] implements [OnAllChangesDone].
|
/// Checks if an [Identifier] implements [AfterContentChecked].
|
||||||
bool isOnAllChangesDone(Identifier typeName, AssetId assetId) => implements(
|
bool isAfterContentChecked(Identifier typeName, AssetId assetId) => implements(
|
||||||
firstMatch(typeName, assetId), _ON_ALL_CHANGES_DONE_INTERFACES);
|
firstMatch(typeName, assetId), _ON_ALL_CHANGES_DONE_INTERFACES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ class _NgDepsDeclarationsVisitor extends Object with SimpleAstVisitor<Object> {
|
||||||
final AnnotationMatcher _annotationMatcher;
|
final AnnotationMatcher _annotationMatcher;
|
||||||
|
|
||||||
/// Responsible for testing whether interfaces are recognized by Angular2,
|
/// Responsible for testing whether interfaces are recognized by Angular2,
|
||||||
/// for example `OnChange`.
|
/// for example `OnChanges`.
|
||||||
final InterfaceMatcher _interfaceMatcher;
|
final InterfaceMatcher _interfaceMatcher;
|
||||||
|
|
||||||
/// Used to fetch linked files.
|
/// Used to fetch linked files.
|
||||||
|
|
|
@ -256,23 +256,23 @@ class AnnotationsTransformVisitor extends ToSourceVisitor {
|
||||||
|
|
||||||
namesToTest.forEach((name) {
|
namesToTest.forEach((name) {
|
||||||
if (_interfaceMatcher.isOnChange(name, _assetId)) {
|
if (_interfaceMatcher.isOnChange(name, _assetId)) {
|
||||||
_ifaceLifecycleEntries.add('${LifecycleEvent.onChange}');
|
_ifaceLifecycleEntries.add('${LifecycleEvent.OnChanges}');
|
||||||
populateImport(name);
|
populateImport(name);
|
||||||
}
|
}
|
||||||
if (_interfaceMatcher.isOnDestroy(name, _assetId)) {
|
if (_interfaceMatcher.isOnDestroy(name, _assetId)) {
|
||||||
_ifaceLifecycleEntries.add('${LifecycleEvent.onDestroy}');
|
_ifaceLifecycleEntries.add('${LifecycleEvent.OnDestroy}');
|
||||||
populateImport(name);
|
populateImport(name);
|
||||||
}
|
}
|
||||||
if (_interfaceMatcher.isOnCheck(name, _assetId)) {
|
if (_interfaceMatcher.isOnCheck(name, _assetId)) {
|
||||||
_ifaceLifecycleEntries.add('${LifecycleEvent.onCheck}');
|
_ifaceLifecycleEntries.add('${LifecycleEvent.DoCheck}');
|
||||||
populateImport(name);
|
populateImport(name);
|
||||||
}
|
}
|
||||||
if (_interfaceMatcher.isOnInit(name, _assetId)) {
|
if (_interfaceMatcher.isOnInit(name, _assetId)) {
|
||||||
_ifaceLifecycleEntries.add('${LifecycleEvent.onInit}');
|
_ifaceLifecycleEntries.add('${LifecycleEvent.OnInit}');
|
||||||
populateImport(name);
|
populateImport(name);
|
||||||
}
|
}
|
||||||
if (_interfaceMatcher.isOnAllChangesDone(name, _assetId)) {
|
if (_interfaceMatcher.isAfterContentChecked(name, _assetId)) {
|
||||||
_ifaceLifecycleEntries.add('${LifecycleEvent.onAllChangesDone}');
|
_ifaceLifecycleEntries.add('${LifecycleEvent.AfterContentChecked}');
|
||||||
populateImport(name);
|
populateImport(name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -151,7 +151,7 @@ class _CodegenState {
|
||||||
|
|
||||||
${_genCheckNoChanges()}
|
${_genCheckNoChanges()}
|
||||||
|
|
||||||
${_maybeGenCallOnAllChangesDone()}
|
${_maybeGenCallAfterContentChecked()}
|
||||||
|
|
||||||
${_maybeGenHydrateDirectives()}
|
${_maybeGenHydrateDirectives()}
|
||||||
|
|
||||||
|
@ -260,19 +260,19 @@ class _CodegenState {
|
||||||
'{ $hydrateDirectivesCode $hydrateDetectorsCode }';
|
'{ $hydrateDirectivesCode $hydrateDetectorsCode }';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates calls to `onAllChangesDone` for all `Directive`s that request
|
/// Generates calls to `afterContentChecked` for all `Directive`s that request
|
||||||
/// them.
|
/// them.
|
||||||
String _maybeGenCallOnAllChangesDone() {
|
String _maybeGenCallAfterContentChecked() {
|
||||||
// NOTE(kegluneq): Order is important!
|
// NOTE(kegluneq): Order is important!
|
||||||
var directiveNotifications = _directiveRecords.reversed
|
var directiveNotifications = _directiveRecords.reversed
|
||||||
.where((rec) => rec.callOnAllChangesDone)
|
.where((rec) => rec.callAfterContentChecked)
|
||||||
.map((rec) =>
|
.map((rec) =>
|
||||||
'${_names.getDirectiveName(rec.directiveIndex)}.onAllChangesDone();');
|
'${_names.getDirectiveName(rec.directiveIndex)}.afterContentChecked();');
|
||||||
|
|
||||||
if (directiveNotifications.isNotEmpty) {
|
if (directiveNotifications.isNotEmpty) {
|
||||||
return '''
|
return '''
|
||||||
void callOnAllChangesDone() {
|
void callAfterContentChecked() {
|
||||||
${_names.getDispatcherName()}.notifyOnAllChangesDone();
|
${_names.getDispatcherName()}.notifyAfterContentChecked();
|
||||||
${directiveNotifications.join('')}
|
${directiveNotifications.join('')}
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
|
@ -309,12 +309,12 @@ class _CodegenState {
|
||||||
}
|
}
|
||||||
|
|
||||||
String _genDirectiveLifecycle(ProtoRecord r) {
|
String _genDirectiveLifecycle(ProtoRecord r) {
|
||||||
if (r.name == 'onCheck') {
|
if (r.name == 'DoCheck') {
|
||||||
return _genOnCheck(r);
|
return _genDoCheck(r);
|
||||||
} else if (r.name == 'onInit') {
|
} else if (r.name == 'OnInit') {
|
||||||
return _genOnInit(r);
|
return _genOnInit(r);
|
||||||
} else if (r.name == 'onChange') {
|
} else if (r.name == 'OnChanges') {
|
||||||
return _genOnChange(r);
|
return _genOnChanges(r);
|
||||||
} else {
|
} else {
|
||||||
throw new BaseException("Unknown lifecycle event '${r.name}'");
|
throw new BaseException("Unknown lifecycle event '${r.name}'");
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ class _CodegenState {
|
||||||
String _genAddToChanges(ProtoRecord r) {
|
String _genAddToChanges(ProtoRecord r) {
|
||||||
var newValue = _names.getLocalName(r.selfIndex);
|
var newValue = _names.getLocalName(r.selfIndex);
|
||||||
var oldValue = _names.getFieldName(r.selfIndex);
|
var oldValue = _names.getFieldName(r.selfIndex);
|
||||||
if (!r.bindingRecord.callOnChange()) return '';
|
if (!r.bindingRecord.callOnChanges()) return '';
|
||||||
return "$_CHANGES_LOCAL = addChange($_CHANGES_LOCAL, $oldValue, $newValue);";
|
return "$_CHANGES_LOCAL = addChange($_CHANGES_LOCAL, $oldValue, $newValue);";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,10 +457,10 @@ class _CodegenState {
|
||||||
''';
|
''';
|
||||||
}
|
}
|
||||||
|
|
||||||
String _genOnCheck(ProtoRecord r) {
|
String _genDoCheck(ProtoRecord r) {
|
||||||
var br = r.bindingRecord;
|
var br = r.bindingRecord;
|
||||||
return 'if (!throwOnChange) '
|
return 'if (!throwOnChange) '
|
||||||
'${_names.getDirectiveName(br.directiveRecord.directiveIndex)}.onCheck();';
|
'${_names.getDirectiveName(br.directiveRecord.directiveIndex)}.doCheck();';
|
||||||
}
|
}
|
||||||
|
|
||||||
String _genOnInit(ProtoRecord r) {
|
String _genOnInit(ProtoRecord r) {
|
||||||
|
@ -469,11 +469,11 @@ class _CodegenState {
|
||||||
'${_names.getDirectiveName(br.directiveRecord.directiveIndex)}.onInit();';
|
'${_names.getDirectiveName(br.directiveRecord.directiveIndex)}.onInit();';
|
||||||
}
|
}
|
||||||
|
|
||||||
String _genOnChange(ProtoRecord r) {
|
String _genOnChanges(ProtoRecord r) {
|
||||||
var br = r.bindingRecord;
|
var br = r.bindingRecord;
|
||||||
return 'if (!throwOnChange && $_CHANGES_LOCAL != null) '
|
return 'if (!throwOnChange && $_CHANGES_LOCAL != null) '
|
||||||
'${_names.getDirectiveName(br.directiveRecord.directiveIndex)}'
|
'${_names.getDirectiveName(br.directiveRecord.directiveIndex)}'
|
||||||
'.onChange($_CHANGES_LOCAL);';
|
'.onChanges($_CHANGES_LOCAL);';
|
||||||
}
|
}
|
||||||
|
|
||||||
String _genNotifyOnPushDetectors(ProtoRecord r) {
|
String _genNotifyOnPushDetectors(ProtoRecord r) {
|
||||||
|
|
|
@ -23,10 +23,10 @@ main() {
|
||||||
type: RenderDirectiveMetadata.COMPONENT_TYPE,
|
type: RenderDirectiveMetadata.COMPONENT_TYPE,
|
||||||
exportAs: "aaa",
|
exportAs: "aaa",
|
||||||
callOnDestroy: true,
|
callOnDestroy: true,
|
||||||
callOnChange: true,
|
callOnChanges: true,
|
||||||
callOnCheck: true,
|
callDoCheck: true,
|
||||||
callOnInit: true,
|
callOnInit: true,
|
||||||
callOnAllChangesDone: true,
|
callAfterContentChecked: true,
|
||||||
events: ["onFoo", "onBar"],
|
events: ["onFoo", "onBar"],
|
||||||
changeDetection: ChangeDetectionStrategy.CheckOnce);
|
changeDetection: ChangeDetectionStrategy.CheckOnce);
|
||||||
var map = directiveMetadataToMap(someComponent);
|
var map = directiveMetadataToMap(someComponent);
|
||||||
|
@ -43,10 +43,10 @@ main() {
|
||||||
expect(map["selector"]).toEqual("some-comp");
|
expect(map["selector"]).toEqual("some-comp");
|
||||||
expect(map["type"]).toEqual(RenderDirectiveMetadata.COMPONENT_TYPE);
|
expect(map["type"]).toEqual(RenderDirectiveMetadata.COMPONENT_TYPE);
|
||||||
expect(map["callOnDestroy"]).toEqual(true);
|
expect(map["callOnDestroy"]).toEqual(true);
|
||||||
expect(map["callOnCheck"]).toEqual(true);
|
expect(map["callDoCheck"]).toEqual(true);
|
||||||
expect(map["callOnChange"]).toEqual(true);
|
expect(map["callOnChanges"]).toEqual(true);
|
||||||
expect(map["callOnInit"]).toEqual(true);
|
expect(map["callOnInit"]).toEqual(true);
|
||||||
expect(map["callOnAllChangesDone"]).toEqual(true);
|
expect(map["callAfterContentChecked"]).toEqual(true);
|
||||||
expect(map["exportAs"]).toEqual("aaa");
|
expect(map["exportAs"]).toEqual("aaa");
|
||||||
expect(map["events"]).toEqual(["onFoo", "onBar"]);
|
expect(map["events"]).toEqual(["onFoo", "onBar"]);
|
||||||
expect(map["changeDetection"]).toEqual(ChangeDetectionStrategy.CheckOnce.index);
|
expect(map["changeDetection"]).toEqual(ChangeDetectionStrategy.CheckOnce.index);
|
||||||
|
@ -64,10 +64,10 @@ main() {
|
||||||
["type", RenderDirectiveMetadata.DIRECTIVE_TYPE],
|
["type", RenderDirectiveMetadata.DIRECTIVE_TYPE],
|
||||||
["exportAs", "aaa"],
|
["exportAs", "aaa"],
|
||||||
["callOnDestroy", true],
|
["callOnDestroy", true],
|
||||||
["callOnCheck", true],
|
["callDoCheck", true],
|
||||||
["callOnInit", true],
|
["callOnInit", true],
|
||||||
["callOnChange", true],
|
["callOnChanges", true],
|
||||||
["callOnAllChangesDone", true],
|
["callAfterContentChecked", true],
|
||||||
["events", ["onFoo", "onBar"]],
|
["events", ["onFoo", "onBar"]],
|
||||||
["changeDetection", ChangeDetectionStrategy.CheckOnce.index]
|
["changeDetection", ChangeDetectionStrategy.CheckOnce.index]
|
||||||
]);
|
]);
|
||||||
|
@ -86,10 +86,10 @@ main() {
|
||||||
expect(meta.type).toEqual(RenderDirectiveMetadata.DIRECTIVE_TYPE);
|
expect(meta.type).toEqual(RenderDirectiveMetadata.DIRECTIVE_TYPE);
|
||||||
expect(meta.exportAs).toEqual("aaa");
|
expect(meta.exportAs).toEqual("aaa");
|
||||||
expect(meta.callOnDestroy).toEqual(true);
|
expect(meta.callOnDestroy).toEqual(true);
|
||||||
expect(meta.callOnCheck).toEqual(true);
|
expect(meta.callDoCheck).toEqual(true);
|
||||||
expect(meta.callOnInit).toEqual(true);
|
expect(meta.callOnInit).toEqual(true);
|
||||||
expect(meta.callOnChange).toEqual(true);
|
expect(meta.callOnChanges).toEqual(true);
|
||||||
expect(meta.callOnAllChangesDone).toEqual(true);
|
expect(meta.callAfterContentChecked).toEqual(true);
|
||||||
expect(meta.events).toEqual(["onFoo", "onBar"]);
|
expect(meta.events).toEqual(["onFoo", "onBar"]);
|
||||||
expect(meta.changeDetection).toEqual(ChangeDetectionStrategy.CheckOnce);
|
expect(meta.changeDetection).toEqual(ChangeDetectionStrategy.CheckOnce);
|
||||||
});
|
});
|
||||||
|
|
|
@ -103,10 +103,10 @@ void allTests() {
|
||||||
var metadata = await readMetadata('directive_metadata_extractor/'
|
var metadata = await readMetadata('directive_metadata_extractor/'
|
||||||
'directive_metadata_files/lifecycle.ng_deps.dart');
|
'directive_metadata_files/lifecycle.ng_deps.dart');
|
||||||
expect(metadata.callOnDestroy).toBe(true);
|
expect(metadata.callOnDestroy).toBe(true);
|
||||||
expect(metadata.callOnChange).toBe(true);
|
expect(metadata.callOnChanges).toBe(true);
|
||||||
expect(metadata.callOnCheck).toBe(true);
|
expect(metadata.callDoCheck).toBe(true);
|
||||||
expect(metadata.callOnInit).toBe(true);
|
expect(metadata.callOnInit).toBe(true);
|
||||||
expect(metadata.callOnAllChangesDone).toBe(true);
|
expect(metadata.callAfterContentChecked).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should parse events.', () async {
|
it('should parse events.', () async {
|
||||||
|
|
|
@ -13,11 +13,11 @@ void initReflector(reflector) {
|
||||||
HelloCmp,
|
HelloCmp,
|
||||||
new ReflectionInfo(const [
|
new ReflectionInfo(const [
|
||||||
const Component(lifecycle: [
|
const Component(lifecycle: [
|
||||||
LifecycleEvent.onChange,
|
LifecycleEvent.OnChanges,
|
||||||
LifecycleEvent.onDestroy,
|
LifecycleEvent.OnDestroy,
|
||||||
LifecycleEvent.onInit,
|
LifecycleEvent.OnInit,
|
||||||
LifecycleEvent.onCheck,
|
LifecycleEvent.DoCheck,
|
||||||
LifecycleEvent.onAllChangesDone
|
LifecycleEvent.AfterContentChecked
|
||||||
])
|
])
|
||||||
], const [
|
], const [
|
||||||
const []
|
const []
|
||||||
|
|
|
@ -16,18 +16,18 @@ void initReflector() {
|
||||||
const [
|
const [
|
||||||
const Component(
|
const Component(
|
||||||
selector: '[soup]',
|
selector: '[soup]',
|
||||||
lifecycle: const [LifecycleEvent.onChange])
|
lifecycle: const [LifecycleEvent.OnChanges])
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
() => new OnChangeSoupComponent(),
|
() => new OnChangeSoupComponent(),
|
||||||
const [OnChange]))
|
const [OnChanges]))
|
||||||
..registerType(
|
..registerType(
|
||||||
OnDestroySoupComponent,
|
OnDestroySoupComponent,
|
||||||
new _ngRef.ReflectionInfo(
|
new _ngRef.ReflectionInfo(
|
||||||
const [
|
const [
|
||||||
const Component(
|
const Component(
|
||||||
selector: '[soup]',
|
selector: '[soup]',
|
||||||
lifecycle: const [LifecycleEvent.onDestroy])
|
lifecycle: const [LifecycleEvent.OnDestroy])
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
() => new OnDestroySoupComponent(),
|
() => new OnDestroySoupComponent(),
|
||||||
|
@ -37,30 +37,30 @@ void initReflector() {
|
||||||
new _ngRef.ReflectionInfo(
|
new _ngRef.ReflectionInfo(
|
||||||
const [
|
const [
|
||||||
const Component(
|
const Component(
|
||||||
selector: '[soup]', lifecycle: const [LifecycleEvent.onCheck])
|
selector: '[soup]', lifecycle: const [LifecycleEvent.DoCheck])
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
() => new OnCheckSoupComponent(),
|
() => new OnCheckSoupComponent(),
|
||||||
const [OnCheck]))
|
const [DoCheck]))
|
||||||
..registerType(
|
..registerType(
|
||||||
OnInitSoupComponent,
|
OnInitSoupComponent,
|
||||||
new _ngRef.ReflectionInfo(
|
new _ngRef.ReflectionInfo(
|
||||||
const [
|
const [
|
||||||
const Component(
|
const Component(
|
||||||
selector: '[soup]', lifecycle: const [LifecycleEvent.onInit])
|
selector: '[soup]', lifecycle: const [LifecycleEvent.OnInit])
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
() => new OnInitSoupComponent(),
|
() => new OnInitSoupComponent(),
|
||||||
const [OnInit]))
|
const [OnInit]))
|
||||||
..registerType(
|
..registerType(
|
||||||
OnAllChangesDoneSoupComponent,
|
AfterContentCheckedSoupComponent,
|
||||||
new _ngRef.ReflectionInfo(
|
new _ngRef.ReflectionInfo(
|
||||||
const [
|
const [
|
||||||
const Component(
|
const Component(
|
||||||
selector: '[soup]',
|
selector: '[soup]',
|
||||||
lifecycle: const [LifecycleEvent.onAllChangesDone])
|
lifecycle: const [LifecycleEvent.AfterContentChecked])
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
() => new OnAllChangesDoneSoupComponent(),
|
() => new AfterContentCheckedSoupComponent(),
|
||||||
const [OnAllChangesDone]));
|
const [AfterContentChecked]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,16 @@ library dinner.soup;
|
||||||
import 'package:angular2/metadata.dart';
|
import 'package:angular2/metadata.dart';
|
||||||
|
|
||||||
@Component(selector: '[soup]')
|
@Component(selector: '[soup]')
|
||||||
class OnChangeSoupComponent implements OnChange {}
|
class OnChangeSoupComponent implements OnChanges {}
|
||||||
|
|
||||||
@Component(selector: '[soup]')
|
@Component(selector: '[soup]')
|
||||||
class OnDestroySoupComponent implements OnDestroy {}
|
class OnDestroySoupComponent implements OnDestroy {}
|
||||||
|
|
||||||
@Component(selector: '[soup]')
|
@Component(selector: '[soup]')
|
||||||
class OnCheckSoupComponent implements OnCheck {}
|
class OnCheckSoupComponent implements DoCheck {}
|
||||||
|
|
||||||
@Component(selector: '[soup]')
|
@Component(selector: '[soup]')
|
||||||
class OnInitSoupComponent implements OnInit {}
|
class OnInitSoupComponent implements OnInit {}
|
||||||
|
|
||||||
@Component(selector: '[soup]')
|
@Component(selector: '[soup]')
|
||||||
class OnAllChangesDoneSoupComponent implements OnAllChangesDone {}
|
class AfterContentCheckedSoupComponent implements AfterContentChecked {}
|
||||||
|
|
|
@ -16,5 +16,5 @@ void initReflector() {
|
||||||
const [const Component(selector: '[soup]')],
|
const [const Component(selector: '[soup]')],
|
||||||
const [],
|
const [],
|
||||||
() => new ChangingSoupComponent(),
|
() => new ChangingSoupComponent(),
|
||||||
const [OnChange, AnotherInterface]));
|
const [OnChanges, AnotherInterface]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,4 @@ library dinner.soup;
|
||||||
import 'package:angular2/src/core/metadata.dart';
|
import 'package:angular2/src/core/metadata.dart';
|
||||||
|
|
||||||
@Component(selector: '[soup]')
|
@Component(selector: '[soup]')
|
||||||
class ChangingSoupComponent implements OnChange, AnotherInterface {}
|
class ChangingSoupComponent implements OnChanges, AnotherInterface {}
|
||||||
|
|
|
@ -17,14 +17,14 @@ void initReflector() {
|
||||||
const Component(
|
const Component(
|
||||||
selector: '[soup]',
|
selector: '[soup]',
|
||||||
lifecycle: const [
|
lifecycle: const [
|
||||||
LifecycleEvent.onChange,
|
LifecycleEvent.OnChanges,
|
||||||
LifecycleEvent.onDestroy,
|
LifecycleEvent.OnDestroy,
|
||||||
LifecycleEvent.onInit
|
LifecycleEvent.OnInit
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
() => new MultiSoupComponent(),
|
() => new MultiSoupComponent(),
|
||||||
const [OnChange, OnDestroy, OnInit]))
|
const [OnChanges, OnDestroy, OnInit]))
|
||||||
..registerType(
|
..registerType(
|
||||||
MixedSoupComponent,
|
MixedSoupComponent,
|
||||||
new _ngRef.ReflectionInfo(
|
new _ngRef.ReflectionInfo(
|
||||||
|
@ -32,22 +32,22 @@ void initReflector() {
|
||||||
const Component(
|
const Component(
|
||||||
selector: '[soup]',
|
selector: '[soup]',
|
||||||
lifecycle: const [
|
lifecycle: const [
|
||||||
LifecycleEvent.onChange,
|
LifecycleEvent.DoCheck,
|
||||||
LifecycleEvent.onCheck
|
LifecycleEvent.OnChanges
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
() => new MixedSoupComponent(),
|
() => new MixedSoupComponent(),
|
||||||
const [OnChange]))
|
const [OnChanges]))
|
||||||
..registerType(
|
..registerType(
|
||||||
MatchedSoupComponent,
|
MatchedSoupComponent,
|
||||||
new _ngRef.ReflectionInfo(
|
new _ngRef.ReflectionInfo(
|
||||||
const [
|
const [
|
||||||
const Component(
|
const Component(
|
||||||
selector: '[soup]',
|
selector: '[soup]',
|
||||||
lifecycle: const [LifecycleEvent.onChange])
|
lifecycle: const [LifecycleEvent.OnChanges])
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
() => new MatchedSoupComponent(),
|
() => new MatchedSoupComponent(),
|
||||||
const [OnChange]));
|
const [OnChanges]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@ library dinner.soup;
|
||||||
import 'package:angular2/metadata.dart';
|
import 'package:angular2/metadata.dart';
|
||||||
|
|
||||||
@Component(selector: '[soup]')
|
@Component(selector: '[soup]')
|
||||||
class MultiSoupComponent implements OnChange, OnDestroy, OnInit {}
|
class MultiSoupComponent implements OnChanges, OnDestroy, OnInit {}
|
||||||
|
|
||||||
@Component(selector: '[soup]', lifecycle: const [LifecycleEvent.onCheck])
|
@Component(selector: '[soup]', lifecycle: const [LifecycleEvent.DoCheck])
|
||||||
class MixedSoupComponent implements OnChange {}
|
class MixedSoupComponent implements OnChanges {}
|
||||||
|
|
||||||
@Component(selector: '[soup]', lifecycle: const [LifecycleEvent.onChange])
|
@Component(selector: '[soup]', lifecycle: const [LifecycleEvent.OnChanges])
|
||||||
class MatchedSoupComponent implements OnChange {}
|
class MatchedSoupComponent implements OnChanges {}
|
||||||
|
|
|
@ -16,9 +16,9 @@ void initReflector() {
|
||||||
const [
|
const [
|
||||||
const prefix.Component(
|
const prefix.Component(
|
||||||
selector: '[soup]',
|
selector: '[soup]',
|
||||||
lifecycle: const [prefix.LifecycleEvent.onChange])
|
lifecycle: const [prefix.LifecycleEvent.OnChanges])
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
() => new OnChangeSoupComponent(),
|
() => new OnChangeSoupComponent(),
|
||||||
const [prefix.OnChange]));
|
const [prefix.OnChanges]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,4 @@ library dinner.soup;
|
||||||
import 'package:angular2/metadata.dart' as prefix;
|
import 'package:angular2/metadata.dart' as prefix;
|
||||||
|
|
||||||
@prefix.Component(selector: '[soup]')
|
@prefix.Component(selector: '[soup]')
|
||||||
class OnChangeSoupComponent implements prefix.OnChange {}
|
class OnChangeSoupComponent implements prefix.OnChanges {}
|
||||||
|
|
|
@ -14,6 +14,6 @@ void initReflector() {
|
||||||
OnChangeSoupComponent,
|
OnChangeSoupComponent,
|
||||||
new _ngRef.ReflectionInfo(const [
|
new _ngRef.ReflectionInfo(const [
|
||||||
const Component(
|
const Component(
|
||||||
selector: '[soup]', lifecycle: const [LifecycleEvent.onChange])
|
selector: '[soup]', lifecycle: const [LifecycleEvent.OnChanges])
|
||||||
], const [], () => new OnChangeSoupComponent()));
|
], const [], () => new OnChangeSoupComponent()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,4 @@ library dinner.soup;
|
||||||
import 'package:angular2/metadata.dart';
|
import 'package:angular2/metadata.dart';
|
||||||
|
|
||||||
@Component(selector: '[soup]')
|
@Component(selector: '[soup]')
|
||||||
class OnChangeSoupComponent extends OnChange {}
|
class OnChangeSoupComponent extends OnChanges {}
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": false,
|
"callOnDestroy": false,
|
||||||
"callOnCheck": false,
|
"callDoCheck": false,
|
||||||
"callOnInit": false,
|
"callOnInit": false,
|
||||||
"callOnChange": false,
|
"callOnChanges": false,
|
||||||
"callOnAllChangesDone": false,
|
"callAfterContentChecked": false,
|
||||||
"events": [],
|
"events": [],
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
"type": null,
|
"type": null,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": null,
|
"callOnDestroy": null,
|
||||||
"callOnCheck": null,
|
"callDoCheck": null,
|
||||||
"callOnInit": null,
|
"callOnInit": null,
|
||||||
"callOnChange": null,
|
"callOnChanges": null,
|
||||||
"callOnAllChangesDone": null,
|
"callAfterContentChecked": null,
|
||||||
"events": ["dependencyEventName"],
|
"events": ["dependencyEventName"],
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -36,10 +36,10 @@
|
||||||
"type": null,
|
"type": null,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": null,
|
"callOnDestroy": null,
|
||||||
"callOnCheck": null,
|
"callDoCheck": null,
|
||||||
"callOnInit": null,
|
"callOnInit": null,
|
||||||
"callOnChange": null,
|
"callOnChanges": null,
|
||||||
"callOnAllChangesDone": null,
|
"callAfterContentChecked": null,
|
||||||
"events": null,
|
"events": null,
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -59,10 +59,10 @@
|
||||||
"type": null,
|
"type": null,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": null,
|
"callOnDestroy": null,
|
||||||
"callOnCheck": null,
|
"callDoCheck": null,
|
||||||
"callOnInit": null,
|
"callOnInit": null,
|
||||||
"callOnChange": null,
|
"callOnChanges": null,
|
||||||
"callOnAllChangesDone": null,
|
"callAfterContentChecked": null,
|
||||||
"events": null,
|
"events": null,
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -82,10 +82,10 @@
|
||||||
"type": null,
|
"type": null,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": null,
|
"callOnDestroy": null,
|
||||||
"callOnCheck": true,
|
"callDoCheck": true,
|
||||||
"callOnInit": null,
|
"callOnInit": null,
|
||||||
"callOnChange": null,
|
"callOnChanges": null,
|
||||||
"callOnAllChangesDone": null,
|
"callAfterContentChecked": null,
|
||||||
"events": null,
|
"events": null,
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
"type": null,
|
"type": null,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": null,
|
"callOnDestroy": null,
|
||||||
"callOnCheck": null,
|
"callDoCheck": null,
|
||||||
"callOnInit": null,
|
"callOnInit": null,
|
||||||
"callOnChange": null,
|
"callOnChanges": null,
|
||||||
"callOnAllChangesDone": null,
|
"callAfterContentChecked": null,
|
||||||
"events": null,
|
"events": null,
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -36,10 +36,10 @@
|
||||||
"type": 0,
|
"type": 0,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": false,
|
"callOnDestroy": false,
|
||||||
"callOnCheck": false,
|
"callDoCheck": false,
|
||||||
"callOnInit": false,
|
"callOnInit": false,
|
||||||
"callOnChange": false,
|
"callOnChanges": false,
|
||||||
"callOnAllChangesDone": false,
|
"callAfterContentChecked": false,
|
||||||
"events": [],
|
"events": [],
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -59,10 +59,10 @@
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": false,
|
"callOnDestroy": false,
|
||||||
"callOnCheck": false,
|
"callDoCheck": false,
|
||||||
"callOnInit": false,
|
"callOnInit": false,
|
||||||
"callOnChange": false,
|
"callOnChanges": false,
|
||||||
"callOnAllChangesDone": false,
|
"callAfterContentChecked": false,
|
||||||
"events": ["eventName"],
|
"events": ["eventName"],
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -82,10 +82,10 @@
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": false,
|
"callOnDestroy": false,
|
||||||
"callOnCheck": false,
|
"callDoCheck": false,
|
||||||
"callOnInit": false,
|
"callOnInit": false,
|
||||||
"callOnChange": false,
|
"callOnChanges": false,
|
||||||
"callOnAllChangesDone": false,
|
"callAfterContentChecked": false,
|
||||||
"events": [],
|
"events": [],
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -105,10 +105,10 @@
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": false,
|
"callOnDestroy": false,
|
||||||
"callOnCheck": false,
|
"callDoCheck": false,
|
||||||
"callOnInit": false,
|
"callOnInit": false,
|
||||||
"callOnChange": false,
|
"callOnChanges": false,
|
||||||
"callOnAllChangesDone": false,
|
"callAfterContentChecked": false,
|
||||||
"events": [],
|
"events": [],
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -128,10 +128,10 @@
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": false,
|
"callOnDestroy": false,
|
||||||
"callOnCheck": false,
|
"callDoCheck": false,
|
||||||
"callOnInit": false,
|
"callOnInit": false,
|
||||||
"callOnChange": false,
|
"callOnChanges": false,
|
||||||
"callOnAllChangesDone": false,
|
"callAfterContentChecked": false,
|
||||||
"events": [],
|
"events": [],
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -151,10 +151,10 @@
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": false,
|
"callOnDestroy": false,
|
||||||
"callOnCheck": false,
|
"callDoCheck": false,
|
||||||
"callOnInit": false,
|
"callOnInit": false,
|
||||||
"callOnChange": false,
|
"callOnChanges": false,
|
||||||
"callOnAllChangesDone": false,
|
"callAfterContentChecked": false,
|
||||||
"events": [],
|
"events": [],
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
@ -174,10 +174,10 @@
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"exportAs": null,
|
"exportAs": null,
|
||||||
"callOnDestroy": false,
|
"callOnDestroy": false,
|
||||||
"callOnCheck": false,
|
"callDoCheck": false,
|
||||||
"callOnInit": false,
|
"callOnInit": false,
|
||||||
"callOnChange": false,
|
"callOnChanges": false,
|
||||||
"callOnAllChangesDone": false,
|
"callAfterContentChecked": false,
|
||||||
"events": [],
|
"events": [],
|
||||||
"changeDetection": null,
|
"changeDetection": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
|
|
Loading…
Reference in New Issue