refactor(ChangeDetector): use View/ShadowDom & Content/LightDom consistently
This commit is contained in:
@ -26,8 +26,8 @@ class _Context {
|
||||
}
|
||||
|
||||
export class AbstractChangeDetector<T> implements ChangeDetector {
|
||||
lightDomChildren: any[] = [];
|
||||
shadowDomChildren: any[] = [];
|
||||
contentChildren: any[] = [];
|
||||
viewChildren: any[] = [];
|
||||
parent: ChangeDetector;
|
||||
ref: ChangeDetectorRef;
|
||||
|
||||
@ -50,21 +50,21 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
||||
this.ref = new ChangeDetectorRef_(this);
|
||||
}
|
||||
|
||||
addChild(cd: ChangeDetector): void {
|
||||
this.lightDomChildren.push(cd);
|
||||
addContentChild(cd: ChangeDetector): void {
|
||||
this.contentChildren.push(cd);
|
||||
cd.parent = this;
|
||||
}
|
||||
|
||||
removeChild(cd: ChangeDetector): void { ListWrapper.remove(this.lightDomChildren, cd); }
|
||||
removeContentChild(cd: ChangeDetector): void { ListWrapper.remove(this.contentChildren, cd); }
|
||||
|
||||
addShadowDomChild(cd: ChangeDetector): void {
|
||||
this.shadowDomChildren.push(cd);
|
||||
addViewChild(cd: ChangeDetector): void {
|
||||
this.viewChildren.push(cd);
|
||||
cd.parent = this;
|
||||
}
|
||||
|
||||
removeShadowDomChild(cd: ChangeDetector): void { ListWrapper.remove(this.shadowDomChildren, cd); }
|
||||
removeViewChild(cd: ChangeDetector): void { ListWrapper.remove(this.viewChildren, cd); }
|
||||
|
||||
remove(): void { this.parent.removeChild(this); }
|
||||
remove(): void { this.parent.removeContentChild(this); }
|
||||
|
||||
handleEvent(eventName: string, elIndex: number, locals: Locals): boolean {
|
||||
var res = this.handleEventInternal(eventName, elIndex, locals);
|
||||
@ -86,10 +86,10 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
||||
|
||||
this.detectChangesInRecords(throwOnChange);
|
||||
|
||||
this._detectChangesInLightDomChildren(throwOnChange);
|
||||
this._detectChangesContentChildren(throwOnChange);
|
||||
if (!throwOnChange) this.afterContentLifecycleCallbacks();
|
||||
|
||||
this._detectChangesInShadowDomChildren(throwOnChange);
|
||||
this._detectChangesInViewChildren(throwOnChange);
|
||||
if (!throwOnChange) this.afterViewLifecycleCallbacks();
|
||||
|
||||
if (this.mode === ChangeDetectionStrategy.CheckOnce)
|
||||
@ -130,7 +130,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
||||
|
||||
// This method is not intended to be overridden. Subclasses should instead provide an
|
||||
// implementation of `hydrateDirectives`.
|
||||
hydrate(context: T, locals: Locals, directives: any, pipes: any): void {
|
||||
hydrate(context: T, locals: Locals, directives: any, pipes: Pipes): void {
|
||||
this.mode = ChangeDetectionUtil.changeDetectionMode(this.strategy);
|
||||
this.context = context;
|
||||
|
||||
@ -183,16 +183,16 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
||||
afterViewLifecycleCallbacksInternal(): void {}
|
||||
|
||||
/** @internal */
|
||||
_detectChangesInLightDomChildren(throwOnChange: boolean): void {
|
||||
var c = this.lightDomChildren;
|
||||
_detectChangesContentChildren(throwOnChange: boolean): void {
|
||||
var c = this.contentChildren;
|
||||
for (var i = 0; i < c.length; ++i) {
|
||||
c[i].runDetectChanges(throwOnChange);
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
_detectChangesInShadowDomChildren(throwOnChange: boolean): void {
|
||||
var c = this.shadowDomChildren;
|
||||
_detectChangesInViewChildren(throwOnChange: boolean): void {
|
||||
var c = this.viewChildren;
|
||||
for (var i = 0; i < c.length; ++i) {
|
||||
c[i].runDetectChanges(throwOnChange);
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ export class BindingRecord {
|
||||
return isBlank(this.directiveRecord) || this.directiveRecord.isDefaultChangeDetection();
|
||||
}
|
||||
|
||||
|
||||
static createDirectiveDoCheck(directiveRecord: DirectiveRecord): BindingRecord {
|
||||
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "DoCheck", directiveRecord);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ export const CONTEXT_ACCESSOR = "context";
|
||||
export const CONTEXT_INDEX = 0;
|
||||
const _FIELD_PREFIX = 'this.';
|
||||
|
||||
var _whiteSpaceRegExp = RegExpWrapper.create("\\W", "g");
|
||||
var _whiteSpaceRegExp = /\W/g;
|
||||
|
||||
/**
|
||||
* Returns `s` with all non-identifier characters removed.
|
||||
|
@ -22,10 +22,10 @@ export interface ChangeDetector {
|
||||
mode: ChangeDetectionStrategy;
|
||||
ref: ChangeDetectorRef;
|
||||
|
||||
addChild(cd: ChangeDetector): void;
|
||||
addShadowDomChild(cd: ChangeDetector): void;
|
||||
removeChild(cd: ChangeDetector): void;
|
||||
removeShadowDomChild(cd: ChangeDetector): void;
|
||||
addContentChild(cd: ChangeDetector): void;
|
||||
addViewChild(cd: ChangeDetector): void;
|
||||
removeContentChild(cd: ChangeDetector): void;
|
||||
removeViewChild(cd: ChangeDetector): void;
|
||||
remove(): void;
|
||||
hydrate(context: any, locals: Locals, directives: any, pipes: any): void;
|
||||
dehydrate(): void;
|
||||
|
@ -102,7 +102,7 @@ export class AppViewManagerUtils {
|
||||
currentView.init(protoView.changeDetectorFactory(currentView), elementInjectors,
|
||||
rootElementInjectors, preBuiltObjects, views, elementRefs, viewContainers);
|
||||
if (isPresent(parentView) && protoView.type === viewModule.ViewType.COMPONENT) {
|
||||
parentView.changeDetector.addShadowDomChild(currentView.changeDetector);
|
||||
parentView.changeDetector.addViewChild(currentView.changeDetector);
|
||||
}
|
||||
elementOffset += protoView.elementBinders.length;
|
||||
textOffset += protoView.textBindingCount;
|
||||
@ -122,7 +122,7 @@ export class AppViewManagerUtils {
|
||||
contextView = parentView;
|
||||
contextBoundElementIndex = boundElementIndex;
|
||||
}
|
||||
parentView.changeDetector.addChild(view.changeDetector);
|
||||
parentView.changeDetector.addContentChild(view.changeDetector);
|
||||
var viewContainer = parentView.viewContainers[boundElementIndex];
|
||||
if (isBlank(viewContainer)) {
|
||||
viewContainer = new viewModule.AppViewContainer();
|
||||
|
Reference in New Issue
Block a user