tools: added experimentalDecorators flag to tsconfig

This commit is contained in:
vsavkin
2015-07-08 10:28:47 -07:00
parent e0fb50cc3c
commit 4656c6f5cf
20 changed files with 159 additions and 146 deletions

View File

@ -54,27 +54,29 @@ import {
onAllChangesDone
} from 'angular2/src/core/annotations_impl/annotations';
import {hasLifecycleHook} from './directive_lifecycle_reflector';
import {ChangeDetector, ChangeDetectorRef} from 'angular2/change_detection';
import {ChangeDetector, ChangeDetectorRef, PipeRegistry} from 'angular2/change_detection';
import {QueryList} from './query_list';
import {reflector} from 'angular2/src/reflection/reflection';
import {DirectiveMetadata} from 'angular2/src/render/api';
var _staticKeys;
class StaticKeys {
export class StaticKeys {
viewManagerId: number;
protoViewId: number;
viewContainerId: number;
changeDetectorRefId: number;
elementRefId: number;
pipeRegistryKey: Key;
constructor() {
// TODO: vsavkin Key.annotate(Key.get(AppView), 'static')
this.viewManagerId = Key.get(avmModule.AppViewManager).id;
this.protoViewId = Key.get(ProtoViewRef).id;
this.viewContainerId = Key.get(ViewContainerRef).id;
this.changeDetectorRefId = Key.get(ChangeDetectorRef).id;
this.elementRefId = Key.get(ElementRef).id;
// not an id because the public API of injector works only with keys and tokens
this.pipeRegistryKey = Key.get(PipeRegistry);
}
static instance(): StaticKeys {
@ -529,14 +531,15 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
// |boundary
// |
// this._injector
var parent = this._getParentInjector(imperativelyCreatedInjector, host);
var parent = this._closestBoundaryInjector(imperativelyCreatedInjector, host);
this._reattachInjector(this._injector, parent, true);
}
}
private _getParentInjector(injector: Injector, host: ElementInjector): Injector {
if (isPresent(injector)) {
return injector;
private _closestBoundaryInjector(imperativelyCreatedInjector: Injector,
host: ElementInjector): Injector {
if (isPresent(imperativelyCreatedInjector)) {
return imperativelyCreatedInjector;
} else if (isPresent(host)) {
return host._injector;
} else {
@ -549,6 +552,11 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
injector.internalStrategy.hydrate();
}
getPipeRegistry(): PipeRegistry {
var pipeRegistryKey = StaticKeys.instance().pipeRegistryKey;
return this._injector.getOptional(pipeRegistryKey);
}
hasVariableBinding(name: string): boolean {
var vb = this._proto.directiveVariableBindings;
return isPresent(vb) && vb.has(name);

View File

@ -141,12 +141,11 @@ export class AppViewManagerUtils {
var elementInjector = contextView.elementInjectors[contextBoundElementIndex];
var injector = isPresent(bindings) ? Injector.fromResolvedBindings(bindings) : null;
this._hydrateView(view, injector, elementInjector.getHost(), contextView.context,
contextView.locals);
}
_hydrateView(view: viewModule.AppView, injector: Injector,
_hydrateView(view: viewModule.AppView, imperativelyCreatedInjector: Injector,
hostElementInjector: eli.ElementInjector, context: Object, parentLocals: Locals) {
view.context = context;
view.locals.parent = parentLocals;
@ -156,13 +155,24 @@ export class AppViewManagerUtils {
var elementInjector = view.elementInjectors[i];
if (isPresent(elementInjector)) {
elementInjector.hydrate(injector, hostElementInjector, view.preBuiltObjects[i]);
elementInjector.hydrate(imperativelyCreatedInjector, hostElementInjector,
view.preBuiltObjects[i]);
this._populateViewLocals(view, elementInjector);
this._setUpEventEmitters(view, elementInjector, i);
this._setUpHostActions(view, elementInjector, i);
}
}
view.changeDetector.hydrate(view.context, view.locals, view);
var pipeRegistry = this._getPipeRegistry(imperativelyCreatedInjector, hostElementInjector);
view.changeDetector.hydrate(view.context, view.locals, view, pipeRegistry);
}
_getPipeRegistry(imperativelyCreatedInjector: Injector,
hostElementInjector: eli.ElementInjector) {
var pipeRegistryKey = eli.StaticKeys.instance().pipeRegistryKey;
if (isPresent(imperativelyCreatedInjector))
return imperativelyCreatedInjector.getOptional(pipeRegistryKey);
if (isPresent(hostElementInjector)) return hostElementInjector.getPipeRegistry();
return null;
}
_populateViewLocals(view: viewModule.AppView, elementInjector: eli.ElementInjector): void {