refactor: rename all const to UPPER_CASE

Closes #3573

BREAKING CHANGE

Rename:
- `appComponentTypeToken` => `APP_COMPONENT`
- `coreDirectives` => `CORE_DIRECTIVES`
- `formDirectives` => `FORM_DIRECTIVES`
- `formInjectables` => `FORM_BINDINGS`
- `httpInjectables` => `HTTP_BINDINGS`
- `jsonpInjectables` => `JSONP_BINDINGS`
- `PROTO_CHANGE_DETECTOR_KEY` => `PROTO_CHANGE_DETECTOR`
- `appComponentRefPromiseToken` => `APP_COMPONENT_REF_PROMISE`
- `appComponentTypeToken` => `APP_COMPONENT`
- `undefinedValue` => `UNDEFINED`
- `formDirectives` => `FORM_DIRECTIVES`
- `DOCUMENT_TOKEN` => `DOCUMENT`
- `APP_ID_TOKEN` => `APP_ID`
- `MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN` => `MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE`
- `appBaseHrefToken` => `APP_BASE_HREF`
This commit is contained in:
Misko Hevery
2015-08-10 21:42:47 -07:00
parent 1d65b38b28
commit 60af19f0e1
54 changed files with 203 additions and 205 deletions

View File

@ -72,7 +72,7 @@ export const defaultKeyValueDiffers = CONST_EXPR(new KeyValueDiffers(keyValDiff)
// dart2js. See https://github.com/dart-lang/sdk/issues/23630 for details.
export var preGeneratedProtoDetectors: StringMap<string, Function> = {};
export const PROTO_CHANGE_DETECTOR_KEY = CONST_EXPR(new OpaqueToken('ProtoChangeDetectors'));
export const PROTO_CHANGE_DETECTOR = CONST_EXPR(new OpaqueToken('ProtoChangeDetectors'));
/**
* Implements change detection using a map of pregenerated proto detectors.
@ -82,7 +82,7 @@ export class PreGeneratedChangeDetection extends ChangeDetection {
_dynamicChangeDetection: ChangeDetection;
_protoChangeDetectorFactories: StringMap<string, Function>;
constructor(@Inject(PROTO_CHANGE_DETECTOR_KEY) @Optional() protoChangeDetectorsForTest?:
constructor(@Inject(PROTO_CHANGE_DETECTOR) @Optional() protoChangeDetectorsForTest?:
StringMap<string, Function>) {
super();
this._dynamicChangeDetection = new DynamicChangeDetection();

View File

@ -60,11 +60,11 @@ import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
import {Renderer, RenderCompiler} from 'angular2/src/render/api';
import {
DomRenderer,
DOCUMENT_TOKEN,
DOCUMENT,
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES,
DefaultDomCompiler,
APP_ID_RANDOM_BINDING,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE,
TemplateCloner
} from 'angular2/src/render/render';
import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry';
@ -74,7 +74,7 @@ import {
DomSharedStylesHost
} from 'angular2/src/render/dom/view/shared_styles_host';
import {internalView} from 'angular2/src/core/compiler/view_ref';
import {appComponentRefPromiseToken, appComponentTypeToken} from './application_tokens';
import {APP_COMPONENT_REF_PROMISE, APP_COMPONENT} from './application_tokens';
import {wtfInit} from '../profile/wtf_init';
var _rootInjector: Injector;
@ -90,11 +90,11 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
bestChangeDetection = JitChangeDetection;
}
return [
bind(DOCUMENT_TOKEN)
bind(DOCUMENT)
.toValue(DOM.defaultDoc()),
bind(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES).toValue(false),
bind(appComponentTypeToken).toValue(appComponentType),
bind(appComponentRefPromiseToken)
bind(APP_COMPONENT).toValue(appComponentType),
bind(APP_COMPONENT_REF_PROMISE)
.toFactory(
(dynamicComponentLoader, injector, testability, registry) => {
// TODO(rado): investigate whether to support bindings on root component.
@ -107,7 +107,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
[DynamicComponentLoader, Injector, Testability, TestabilityRegistry]),
bind(appComponentType)
.toFactory((p: Promise<any>) => p.then(ref => ref.instance), [appComponentRefPromiseToken]),
.toFactory((p: Promise<any>) => p.then(ref => ref.instance), [APP_COMPONENT_REF_PROMISE]),
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()),
[ExceptionHandler]),
bind(EventManager)
@ -122,7 +122,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
bind(Renderer).toAlias(DomRenderer),
APP_ID_RANDOM_BINDING,
TemplateCloner,
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN).toValue(20),
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(20),
DefaultDomCompiler,
bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),
bind(RenderCompiler).toAlias(DefaultDomCompiler),
@ -305,7 +305,7 @@ export function commonBootstrap(
exceptionHandler = appInjector.get(ExceptionHandler);
zone.overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s));
var compRefToken: Promise<any> = appInjector.get(appComponentRefPromiseToken);
var compRefToken: Promise<any> = appInjector.get(APP_COMPONENT_REF_PROMISE);
var tick = (componentRef) => {
var appChangeDetector = internalView(componentRef.hostView).changeDetector;
// retrieve life cycle: may have already been created if injected in root component

View File

@ -4,7 +4,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
/**
* @private
*/
export const appComponentRefPromiseToken = CONST_EXPR(new OpaqueToken('Promise<ComponentRef>'));
export const APP_COMPONENT_REF_PROMISE = CONST_EXPR(new OpaqueToken('Promise<ComponentRef>'));
/**
* An opaque token representing the application root type in the {@link Injector}.
@ -22,4 +22,4 @@ export const appComponentRefPromiseToken = CONST_EXPR(new OpaqueToken('Promise<C
*
* ```
*/
export const appComponentTypeToken: OpaqueToken = CONST_EXPR(new OpaqueToken('RootComponent'));
export const APP_COMPONENT: OpaqueToken = CONST_EXPR(new OpaqueToken('AppComponent'));

View File

@ -15,7 +15,7 @@ import {
PUBLIC_AND_PRIVATE,
PUBLIC,
PRIVATE,
undefinedValue,
UNDEFINED,
Key,
Dependency,
bind,
@ -645,7 +645,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
}
}
return undefinedValue;
return UNDEFINED;
}
private _buildAttribute(dep: DirectiveDependency): string {
@ -892,41 +892,41 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
var p = i.protoStrategy;
i.resetConstructionCounter();
if (p.binding0 instanceof DirectiveBinding && isPresent(p.keyId0) && i.obj0 === undefinedValue)
if (p.binding0 instanceof DirectiveBinding && isPresent(p.keyId0) && i.obj0 === UNDEFINED)
i.obj0 = i.instantiateBinding(p.binding0, p.visibility0);
if (p.binding1 instanceof DirectiveBinding && isPresent(p.keyId1) && i.obj1 === undefinedValue)
if (p.binding1 instanceof DirectiveBinding && isPresent(p.keyId1) && i.obj1 === UNDEFINED)
i.obj1 = i.instantiateBinding(p.binding1, p.visibility1);
if (p.binding2 instanceof DirectiveBinding && isPresent(p.keyId2) && i.obj2 === undefinedValue)
if (p.binding2 instanceof DirectiveBinding && isPresent(p.keyId2) && i.obj2 === UNDEFINED)
i.obj2 = i.instantiateBinding(p.binding2, p.visibility2);
if (p.binding3 instanceof DirectiveBinding && isPresent(p.keyId3) && i.obj3 === undefinedValue)
if (p.binding3 instanceof DirectiveBinding && isPresent(p.keyId3) && i.obj3 === UNDEFINED)
i.obj3 = i.instantiateBinding(p.binding3, p.visibility3);
if (p.binding4 instanceof DirectiveBinding && isPresent(p.keyId4) && i.obj4 === undefinedValue)
if (p.binding4 instanceof DirectiveBinding && isPresent(p.keyId4) && i.obj4 === UNDEFINED)
i.obj4 = i.instantiateBinding(p.binding4, p.visibility4);
if (p.binding5 instanceof DirectiveBinding && isPresent(p.keyId5) && i.obj5 === undefinedValue)
if (p.binding5 instanceof DirectiveBinding && isPresent(p.keyId5) && i.obj5 === UNDEFINED)
i.obj5 = i.instantiateBinding(p.binding5, p.visibility5);
if (p.binding6 instanceof DirectiveBinding && isPresent(p.keyId6) && i.obj6 === undefinedValue)
if (p.binding6 instanceof DirectiveBinding && isPresent(p.keyId6) && i.obj6 === UNDEFINED)
i.obj6 = i.instantiateBinding(p.binding6, p.visibility6);
if (p.binding7 instanceof DirectiveBinding && isPresent(p.keyId7) && i.obj7 === undefinedValue)
if (p.binding7 instanceof DirectiveBinding && isPresent(p.keyId7) && i.obj7 === UNDEFINED)
i.obj7 = i.instantiateBinding(p.binding7, p.visibility7);
if (p.binding8 instanceof DirectiveBinding && isPresent(p.keyId8) && i.obj8 === undefinedValue)
if (p.binding8 instanceof DirectiveBinding && isPresent(p.keyId8) && i.obj8 === UNDEFINED)
i.obj8 = i.instantiateBinding(p.binding8, p.visibility8);
if (p.binding9 instanceof DirectiveBinding && isPresent(p.keyId9) && i.obj9 === undefinedValue)
if (p.binding9 instanceof DirectiveBinding && isPresent(p.keyId9) && i.obj9 === UNDEFINED)
i.obj9 = i.instantiateBinding(p.binding9, p.visibility9);
}
dehydrate() {
var i = this.injectorStrategy;
i.obj0 = undefinedValue;
i.obj1 = undefinedValue;
i.obj2 = undefinedValue;
i.obj3 = undefinedValue;
i.obj4 = undefinedValue;
i.obj5 = undefinedValue;
i.obj6 = undefinedValue;
i.obj7 = undefinedValue;
i.obj8 = undefinedValue;
i.obj9 = undefinedValue;
i.obj0 = UNDEFINED;
i.obj1 = UNDEFINED;
i.obj2 = UNDEFINED;
i.obj3 = UNDEFINED;
i.obj4 = UNDEFINED;
i.obj5 = UNDEFINED;
i.obj6 = UNDEFINED;
i.obj7 = UNDEFINED;
i.obj8 = UNDEFINED;
i.obj9 = UNDEFINED;
}
callOnDestroy(): void {
@ -1012,43 +1012,43 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
var p = i.protoStrategy;
if (isPresent(p.binding0) && p.binding0.key.token === query.selector) {
if (i.obj0 === undefinedValue) i.obj0 = i.instantiateBinding(p.binding0, p.visibility0);
if (i.obj0 === UNDEFINED) i.obj0 = i.instantiateBinding(p.binding0, p.visibility0);
list.push(i.obj0);
}
if (isPresent(p.binding1) && p.binding1.key.token === query.selector) {
if (i.obj1 === undefinedValue) i.obj1 = i.instantiateBinding(p.binding1, p.visibility1);
if (i.obj1 === UNDEFINED) i.obj1 = i.instantiateBinding(p.binding1, p.visibility1);
list.push(i.obj1);
}
if (isPresent(p.binding2) && p.binding2.key.token === query.selector) {
if (i.obj2 === undefinedValue) i.obj2 = i.instantiateBinding(p.binding2, p.visibility2);
if (i.obj2 === UNDEFINED) i.obj2 = i.instantiateBinding(p.binding2, p.visibility2);
list.push(i.obj2);
}
if (isPresent(p.binding3) && p.binding3.key.token === query.selector) {
if (i.obj3 === undefinedValue) i.obj3 = i.instantiateBinding(p.binding3, p.visibility3);
if (i.obj3 === UNDEFINED) i.obj3 = i.instantiateBinding(p.binding3, p.visibility3);
list.push(i.obj3);
}
if (isPresent(p.binding4) && p.binding4.key.token === query.selector) {
if (i.obj4 === undefinedValue) i.obj4 = i.instantiateBinding(p.binding4, p.visibility4);
if (i.obj4 === UNDEFINED) i.obj4 = i.instantiateBinding(p.binding4, p.visibility4);
list.push(i.obj4);
}
if (isPresent(p.binding5) && p.binding5.key.token === query.selector) {
if (i.obj5 === undefinedValue) i.obj5 = i.instantiateBinding(p.binding5, p.visibility5);
if (i.obj5 === UNDEFINED) i.obj5 = i.instantiateBinding(p.binding5, p.visibility5);
list.push(i.obj5);
}
if (isPresent(p.binding6) && p.binding6.key.token === query.selector) {
if (i.obj6 === undefinedValue) i.obj6 = i.instantiateBinding(p.binding6, p.visibility6);
if (i.obj6 === UNDEFINED) i.obj6 = i.instantiateBinding(p.binding6, p.visibility6);
list.push(i.obj6);
}
if (isPresent(p.binding7) && p.binding7.key.token === query.selector) {
if (i.obj7 === undefinedValue) i.obj7 = i.instantiateBinding(p.binding7, p.visibility7);
if (i.obj7 === UNDEFINED) i.obj7 = i.instantiateBinding(p.binding7, p.visibility7);
list.push(i.obj7);
}
if (isPresent(p.binding8) && p.binding8.key.token === query.selector) {
if (i.obj8 === undefinedValue) i.obj8 = i.instantiateBinding(p.binding8, p.visibility8);
if (i.obj8 === UNDEFINED) i.obj8 = i.instantiateBinding(p.binding8, p.visibility8);
list.push(i.obj8);
}
if (isPresent(p.binding9) && p.binding9.key.token === query.selector) {
if (i.obj9 === undefinedValue) i.obj9 = i.instantiateBinding(p.binding9, p.visibility9);
if (i.obj9 === UNDEFINED) i.obj9 = i.instantiateBinding(p.binding9, p.visibility9);
list.push(i.obj9);
}
}
@ -1072,7 +1072,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
for (var i = 0; i < p.keyIds.length; i++) {
if (p.bindings[i] instanceof DirectiveBinding && isPresent(p.keyIds[i]) &&
inj.objs[i] === undefinedValue) {
inj.objs[i] === UNDEFINED) {
inj.objs[i] = inj.instantiateBinding(p.bindings[i], p.visibilities[i]);
}
}
@ -1080,7 +1080,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
dehydrate(): void {
var inj = this.injectorStrategy;
ListWrapper.fill(inj.objs, undefinedValue);
ListWrapper.fill(inj.objs, UNDEFINED);
}
callOnDestroy(): void {
@ -1119,7 +1119,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
for (var i = 0; i < p.bindings.length; i++) {
if (p.bindings[i].key.token === query.selector) {
if (ist.objs[i] === undefinedValue) {
if (ist.objs[i] === UNDEFINED) {
ist.objs[i] = ist.instantiateBinding(p.bindings[i], p.visibilities[i]);
}
list.push(ist.objs[i]);

View File

@ -36,7 +36,7 @@ export class Dependency {
const _EMPTY_LIST = CONST_EXPR([]);
/**
* Describes how the {@link Injector} should instantiate a given token.
* Describes how_ the {@link Injector} should instantiate a given token.
*
* See {@link bind}.
*

View File

@ -16,7 +16,7 @@ import {SelfMetadata, HostMetadata, SkipSelfMetadata} from './metadata';
// Threshold for the dynamic version
const _MAX_CONSTRUCTION_COUNTER = 10;
export const undefinedValue: Object = CONST_EXPR(new Object());
export const UNDEFINED: Object = CONST_EXPR(new Object());
export const PUBLIC: number = 1;
export const PRIVATE: number = 2;
@ -193,16 +193,16 @@ export interface InjectorStrategy {
}
export class InjectorInlineStrategy implements InjectorStrategy {
obj0: any = undefinedValue;
obj1: any = undefinedValue;
obj2: any = undefinedValue;
obj3: any = undefinedValue;
obj4: any = undefinedValue;
obj5: any = undefinedValue;
obj6: any = undefinedValue;
obj7: any = undefinedValue;
obj8: any = undefinedValue;
obj9: any = undefinedValue;
obj0: any = UNDEFINED;
obj1: any = UNDEFINED;
obj2: any = UNDEFINED;
obj3: any = UNDEFINED;
obj4: any = UNDEFINED;
obj5: any = UNDEFINED;
obj6: any = UNDEFINED;
obj7: any = UNDEFINED;
obj8: any = UNDEFINED;
obj9: any = UNDEFINED;
constructor(public injector: Injector, public protoStrategy: ProtoInjectorInlineStrategy) {}
@ -223,67 +223,67 @@ export class InjectorInlineStrategy implements InjectorStrategy {
var inj = this.injector;
if (p.keyId0 === keyId && (p.visibility0 & visibility) > 0) {
if (this.obj0 === undefinedValue) {
if (this.obj0 === UNDEFINED) {
this.obj0 = inj._new(p.binding0, p.visibility0);
}
return this.obj0;
}
if (p.keyId1 === keyId && (p.visibility1 & visibility) > 0) {
if (this.obj1 === undefinedValue) {
if (this.obj1 === UNDEFINED) {
this.obj1 = inj._new(p.binding1, p.visibility1);
}
return this.obj1;
}
if (p.keyId2 === keyId && (p.visibility2 & visibility) > 0) {
if (this.obj2 === undefinedValue) {
if (this.obj2 === UNDEFINED) {
this.obj2 = inj._new(p.binding2, p.visibility2);
}
return this.obj2;
}
if (p.keyId3 === keyId && (p.visibility3 & visibility) > 0) {
if (this.obj3 === undefinedValue) {
if (this.obj3 === UNDEFINED) {
this.obj3 = inj._new(p.binding3, p.visibility3);
}
return this.obj3;
}
if (p.keyId4 === keyId && (p.visibility4 & visibility) > 0) {
if (this.obj4 === undefinedValue) {
if (this.obj4 === UNDEFINED) {
this.obj4 = inj._new(p.binding4, p.visibility4);
}
return this.obj4;
}
if (p.keyId5 === keyId && (p.visibility5 & visibility) > 0) {
if (this.obj5 === undefinedValue) {
if (this.obj5 === UNDEFINED) {
this.obj5 = inj._new(p.binding5, p.visibility5);
}
return this.obj5;
}
if (p.keyId6 === keyId && (p.visibility6 & visibility) > 0) {
if (this.obj6 === undefinedValue) {
if (this.obj6 === UNDEFINED) {
this.obj6 = inj._new(p.binding6, p.visibility6);
}
return this.obj6;
}
if (p.keyId7 === keyId && (p.visibility7 & visibility) > 0) {
if (this.obj7 === undefinedValue) {
if (this.obj7 === UNDEFINED) {
this.obj7 = inj._new(p.binding7, p.visibility7);
}
return this.obj7;
}
if (p.keyId8 === keyId && (p.visibility8 & visibility) > 0) {
if (this.obj8 === undefinedValue) {
if (this.obj8 === UNDEFINED) {
this.obj8 = inj._new(p.binding8, p.visibility8);
}
return this.obj8;
}
if (p.keyId9 === keyId && (p.visibility9 & visibility) > 0) {
if (this.obj9 === undefinedValue) {
if (this.obj9 === UNDEFINED) {
this.obj9 = inj._new(p.binding9, p.visibility9);
}
return this.obj9;
}
return undefinedValue;
return UNDEFINED;
}
getObjAtIndex(index: number): any {
@ -309,7 +309,7 @@ export class InjectorDynamicStrategy implements InjectorStrategy {
constructor(public protoStrategy: ProtoInjectorDynamicStrategy, public injector: Injector) {
this.objs = ListWrapper.createFixedSize(protoStrategy.bindings.length);
ListWrapper.fill(this.objs, undefinedValue);
ListWrapper.fill(this.objs, UNDEFINED);
}
resetConstructionCounter(): void { this.injector._constructionCounter = 0; }
@ -329,7 +329,7 @@ export class InjectorDynamicStrategy implements InjectorStrategy {
for (var i = 0; i < p.keyIds.length; i++) {
if (p.keyIds[i] === keyId && (p.visibilities[i] & visibility) > 0) {
if (this.objs[i] === undefinedValue) {
if (this.objs[i] === UNDEFINED) {
this.objs[i] = this.injector._new(p.bindings[i], p.visibilities[i]);
}
@ -337,7 +337,7 @@ export class InjectorDynamicStrategy implements InjectorStrategy {
}
}
return undefinedValue;
return UNDEFINED;
}
getObjAtIndex(index: number): any {
@ -693,8 +693,8 @@ export class Injector {
bindingVisibility: number): any {
var special = isPresent(this._depProvider) ?
this._depProvider.getDependency(this, binding, dep) :
undefinedValue;
if (special !== undefinedValue) {
UNDEFINED;
if (special !== UNDEFINED) {
return special;
} else {
return this._getByKey(dep.key, dep.lowerBoundVisibility, dep.upperBoundVisibility,
@ -729,7 +729,7 @@ export class Injector {
_getByKeySelf(key: Key, optional: boolean, bindingVisibility: number): any {
var obj = this._strategy.getObjByKeyId(key.id, bindingVisibility);
return (obj !== undefinedValue) ? obj : this._throwOrNull(key, optional);
return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, optional);
}
_getByKeyHost(key: Key, optional: boolean, bindingVisibility: number,
@ -746,7 +746,7 @@ export class Injector {
while (inj != null) {
var obj = inj._strategy.getObjByKeyId(key.id, bindingVisibility);
if (obj !== undefinedValue) return obj;
if (obj !== UNDEFINED) return obj;
if (isPresent(inj._parent) && inj._isHost) {
return this._getPrivateDependency(key, optional, inj);
@ -760,7 +760,7 @@ export class Injector {
_getPrivateDependency(key: Key, optional: boolean, inj: Injector): any {
var obj = inj._parent._strategy.getObjByKeyId(key.id, PRIVATE);
return (obj !== undefinedValue) ? obj : this._throwOrNull(key, optional);
return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, optional);
}
_getByKeyDefault(key: Key, optional: boolean, bindingVisibility: number,
@ -774,7 +774,7 @@ export class Injector {
while (inj != null) {
var obj = inj._strategy.getObjByKeyId(key.id, bindingVisibility);
if (obj !== undefinedValue) return obj;
if (obj !== UNDEFINED) return obj;
bindingVisibility = inj._isHost ? PUBLIC_AND_PRIVATE : PUBLIC;
inj = inj._parent;

View File

@ -35,7 +35,7 @@ export {NgValidator, NgRequiredValidator} from './directives/validators';
*
* This is a shorthand for importing them each individually.
*/
export const formDirectives: List<Type> = CONST_EXPR([
export const FORM_DIRECTIVES: List<Type> = CONST_EXPR([
NgControlName,
NgControlGroup,

View File

@ -24,7 +24,7 @@ const controlGroupBinding =
* ```
* @Component({selector: "signup-comp"})
* @View({
* directives: [formDirectives],
* directives: [FORM_DIRECTIVES],
* template: `
* <form #f="form" (submit)='onSignUp(f.value)'>
* <div ng-control-group='credentials' #credentials="form">

View File

@ -29,7 +29,7 @@ const controlNameBinding =
* ```
* @Component({selector: "login-comp"})
* @View({
* directives: [formDirectives],
* directives: [FORM_DIRECTIVES],
* template: `
* <form #f="form" (submit)='onLogIn(f.value)'>
* Login <input type='text' ng-control='login' #l="form">
@ -52,7 +52,7 @@ const controlNameBinding =
* ```
* @Component({selector: "login-comp"})
* @View({
* directives: [formDirectives],
* directives: [FORM_DIRECTIVES],
* template: `
* <form (submit)='onLogIn()'>
* Login <input type='text' ng-control='login' [(ng-model)]="credentials.login">

View File

@ -26,7 +26,7 @@ const formDirectiveBinding =
* ```
* @Component({selector: "signup-comp"})
* @View({
* directives: [formDirectives],
* directives: [FORM_DIRECTIVES],
* template: `
* <form #f="form" (submit)='onSignUp(f.value)'>
* <div ng-control-group='credentials' #credentials="form">

View File

@ -27,7 +27,7 @@ const formControlBinding =
* ```
* @Component({selector: "login-comp"})
* @View({
* directives: [formDirectives],
* directives: [FORM_DIRECTIVES],
* template: "<input type='text' [ng-form-control]='loginControl'>"
* })
* class LoginComp {
@ -45,7 +45,7 @@ const formControlBinding =
* ```
* @Component({selector: "login-comp"})
* @View({
* directives: [formDirectives],
* directives: [FORM_DIRECTIVES],
* template: "<input type='text' [ng-form-control]='loginControl' [(ng-model)]='login'>"
* })
* class LoginComp {

View File

@ -26,7 +26,7 @@ const formDirectiveBinding =
* ```
* @Component({selector: "login-comp"})
* @View({
* directives: [formDirectives],
* directives: [FORM_DIRECTIVES],
* template: "<form [ng-form-model]='loginForm'>" +
* "Login <input type='text' ng-control='login'>" +
* "Password <input type='password' ng-control='password'>" +
@ -55,7 +55,7 @@ const formDirectiveBinding =
* ```
* @Component({selector: "login-comp"})
* @View({
* directives: [formDirectives],
* directives: [FORM_DIRECTIVES],
* template: "<form [ng-form-model]='loginForm'>" +
* "Login <input type='text' ng-control='login' [(ng-model)]='login'>" +
* "Password <input type='password' ng-control='password' [(ng-model)]='password'>" +

View File

@ -19,7 +19,7 @@ const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRe
* ```
* @Component({selector: "search-comp"})
* @View({
* directives: [formDirectives],
* directives: [FORM_DIRECTIVES],
* template: `
<input type='text' [(ng-model)]="searchQuery">
* `})

View File

@ -11,7 +11,7 @@ import * as modelModule from './model';
*
* ```
* import {Component, View, bootstrap} from 'angular2/angular2';
* import {FormBuilder, Validators, formDirectives, ControlGroup} from 'angular2/forms';
* import {FormBuilder, Validators, FORM_DIRECTIVES, ControlGroup} from 'angular2/forms';
*
* @Component({
* selector: 'login-comp',
@ -31,7 +31,7 @@ import * as modelModule from './model';
* </form>
* `,
* directives: [
* formDirectives
* FORM_DIRECTIVES
* ]
* })
* class LoginComp {

View File

@ -21,7 +21,7 @@ import {ElementSchemaRegistry} from '../schema/element_schema_registry';
import {Parser} from 'angular2/src/change_detection/change_detection';
import * as pvm from '../view/proto_view_merger';
import {CssSelector} from './selector';
import {DOCUMENT_TOKEN, APP_ID_TOKEN} from '../dom_tokens';
import {DOCUMENT, APP_ID} from '../dom_tokens';
import {Inject} from 'angular2/di';
import {SharedStylesHost} from '../view/shared_styles_host';
import {prependAll} from '../util';
@ -126,7 +126,7 @@ export class DomCompiler extends RenderCompiler {
export class DefaultDomCompiler extends DomCompiler {
constructor(schemaRegistry: ElementSchemaRegistry, templateCloner: TemplateCloner, parser: Parser,
viewLoader: ViewLoader, sharedStylesHost: SharedStylesHost,
@Inject(APP_ID_TOKEN) appId: any) {
@Inject(APP_ID) appId: any) {
super(schemaRegistry, templateCloner, new DefaultStepFactory(parser, appId), viewLoader,
sharedStylesHost);
}

View File

@ -35,7 +35,7 @@ import {
import {TemplateCloner} from './template_cloner';
import {DOCUMENT_TOKEN, DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES} from './dom_tokens';
import {DOCUMENT, DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES} from './dom_tokens';
const REFLECT_PREFIX: string = 'ng-reflect-';
@ -47,7 +47,7 @@ export class DomRenderer extends Renderer {
constructor(private _eventManager: EventManager,
private _domSharedStylesHost: DomSharedStylesHost,
private _templateCloner: TemplateCloner, @Inject(DOCUMENT_TOKEN) document,
private _templateCloner: TemplateCloner, @Inject(DOCUMENT) document,
@Inject(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES) reflectPropertiesAsAttributes:
boolean) {
super();

View File

@ -1,7 +1,7 @@
import {OpaqueToken, bind, Binding} from 'angular2/di';
import {OpaqueToken, Binding} from 'angular2/di';
import {CONST_EXPR, StringWrapper, Math} from 'angular2/src/facade/lang';
export const DOCUMENT_TOKEN: OpaqueToken = CONST_EXPR(new OpaqueToken('DocumentToken'));
export const DOCUMENT: OpaqueToken = CONST_EXPR(new OpaqueToken('DocumentToken'));
export const DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES: OpaqueToken =
CONST_EXPR(new OpaqueToken('DomReflectPropertiesAsAttributes'));
@ -10,19 +10,23 @@ export const DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES: OpaqueToken =
/**
* A unique id (string) for an angular application.
*/
export const APP_ID_TOKEN: OpaqueToken = CONST_EXPR(new OpaqueToken('AppId'));
export const APP_ID: OpaqueToken = CONST_EXPR(new OpaqueToken('AppId'));
function _appIdRandomBindingFactory() {
return `${randomChar()}${randomChar()}${randomChar()}`;
}
/**
* Bindings that will generate a random APP_ID_TOKEN.
*/
export var APP_ID_RANDOM_BINDING: Binding =
bind(APP_ID_TOKEN).toFactory(() => `${randomChar()}${randomChar()}${randomChar()}`, []);
export const APP_ID_RANDOM_BINDING: Binding =
CONST_EXPR(new Binding(APP_ID, {toFactory: _appIdRandomBindingFactory, deps: []}));
/**
* Defines when a compiled template should be stored as a string
* rather than keeping its Nodes to preserve memory.
*/
export const MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN: OpaqueToken =
export const MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE: OpaqueToken =
CONST_EXPR(new OpaqueToken('MaxInMemoryElementsPerTemplate'));
function randomChar(): string {

View File

@ -1,13 +1,13 @@
import {isString} from 'angular2/src/facade/lang';
import {Injectable, Inject} from 'angular2/di';
import {DOM} from 'angular2/src/dom/dom_adapter';
import {MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN} from './dom_tokens';
import {MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE} from './dom_tokens';
@Injectable()
export class TemplateCloner {
maxInMemoryElementsPerTemplate: number;
constructor(@Inject(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN) maxInMemoryElementsPerTemplate) {
constructor(@Inject(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE) maxInMemoryElementsPerTemplate) {
this.maxInMemoryElementsPerTemplate = maxInMemoryElementsPerTemplate;
}

View File

@ -1,7 +1,7 @@
import {DOM} from 'angular2/src/dom/dom_adapter';
import {Inject, Injectable} from 'angular2/di';
import {SetWrapper} from 'angular2/src/facade/collection';
import {DOCUMENT_TOKEN} from '../dom_tokens';
import {DOCUMENT} from '../dom_tokens';
@Injectable()
export class SharedStylesHost {
@ -30,7 +30,7 @@ export class SharedStylesHost {
@Injectable()
export class DomSharedStylesHost extends SharedStylesHost {
private _hostNodes: Set<Node> = new Set();
constructor(@Inject(DOCUMENT_TOKEN) doc: any) {
constructor(@Inject(DOCUMENT) doc: any) {
super();
this._hostNodes.add(doc.head);
}

View File

@ -4,7 +4,7 @@ import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {BaseException, isBlank} from 'angular2/src/facade/lang';
import {OpaqueToken, Injectable, Optional, Inject} from 'angular2/di';
export const appBaseHrefToken: OpaqueToken = CONST_EXPR(new OpaqueToken('locationHrefToken'));
export const APP_BASE_HREF: OpaqueToken = CONST_EXPR(new OpaqueToken('appBaseHref'));
/**
* This is the service that an application developer will directly interact with.
@ -22,7 +22,7 @@ export class Location {
private _baseHref: string;
constructor(public _platformStrategy: LocationStrategy,
@Optional() @Inject(appBaseHrefToken) href?: string) {
@Optional() @Inject(APP_BASE_HREF) href?: string) {
var browserBaseHref = isPresent(href) ? href : this._platformStrategy.getBaseHref();
if (isBlank(browserBaseHref)) {

View File

@ -4,7 +4,7 @@ import {isBlank, isPresent} from 'angular2/src/facade/lang';
import {Directive, Attribute} from 'angular2/src/core/annotations/decorators';
import {DynamicComponentLoader, ComponentRef, ElementRef} from 'angular2/core';
import {Injector, bind, Dependency, undefinedValue} from 'angular2/di';
import {Injector, bind, Dependency, UNDEFINED} from 'angular2/di';
import * as routerMod from './router';
import {Instruction, ComponentInstruction, RouteParams} from './instruction';

View File

@ -16,7 +16,7 @@ import {
import {el} from './utils';
import {DOCUMENT_TOKEN} from 'angular2/src/render/render';
import {DOCUMENT} from 'angular2/src/render/render';
import {DOM} from 'angular2/src/dom/dom_adapter';
import {DebugElement} from 'angular2/src/debug/debug_element';
@ -135,7 +135,7 @@ export class TestComponentBuilder {
var rootElId = `root${_nextRootElementId++}`;
var rootEl = el(`<div id="${rootElId}"></div>`);
var doc = this._injector.get(DOCUMENT_TOKEN);
var doc = this._injector.get(DOCUMENT);
// TODO(juliemr): can/should this be optional?
var oldRoots = DOM.querySelectorAll(doc, '[id^=root]');

View File

@ -53,13 +53,13 @@ import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
import {RenderCompiler, Renderer} from 'angular2/src/render/api';
import {
DomRenderer,
DOCUMENT_TOKEN,
DOCUMENT,
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES,
DefaultDomCompiler,
APP_ID_TOKEN,
APP_ID,
SharedStylesHost,
DomSharedStylesHost,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE,
TemplateCloner
} from 'angular2/src/render/render';
import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry';
@ -99,13 +99,13 @@ function _getAppBindings() {
}
return [
bind(DOCUMENT_TOKEN)
bind(DOCUMENT)
.toValue(appDoc),
DomRenderer,
bind(Renderer).toAlias(DomRenderer),
bind(APP_ID_TOKEN).toValue('a'),
bind(APP_ID).toValue('a'),
TemplateCloner,
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN).toValue(-1),
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(-1),
DefaultDomCompiler,
bind(RenderCompiler).toAlias(DefaultDomCompiler),
bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),

View File

@ -23,11 +23,11 @@ import {Renderer, RenderCompiler} from 'angular2/src/render/api';
import {AppRootUrl} from 'angular2/src/services/app_root_url';
import {
DomRenderer,
DOCUMENT_TOKEN,
DOCUMENT,
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES,
DefaultDomCompiler,
APP_ID_RANDOM_BINDING,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE,
TemplateCloner
} from 'angular2/src/render/render';
import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry';
@ -79,7 +79,7 @@ function _injectorBindings(): List<Type | Binding | List<any>> {
}
return [
bind(DOCUMENT_TOKEN)
bind(DOCUMENT)
.toValue(DOM.defaultDoc()),
bind(EventManager)
.toFactory(
@ -94,7 +94,7 @@ function _injectorBindings(): List<Type | Binding | List<any>> {
bind(Renderer).toAlias(DomRenderer),
APP_ID_RANDOM_BINDING,
TemplateCloner,
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN).toValue(20),
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(20),
DefaultDomCompiler,
bind(RenderCompiler).toAlias(DefaultDomCompiler),
DomSharedStylesHost,

View File

@ -54,10 +54,7 @@ import {internalView} from 'angular2/src/core/compiler/view_ref';
import {MessageBroker} from 'angular2/src/web-workers/worker/broker';
import {WebWorkerMessageBus} from 'angular2/src/web-workers/worker/application';
import {
appComponentRefPromiseToken,
appComponentTypeToken
} from 'angular2/src/core/application_tokens';
import {APP_COMPONENT_REF_PROMISE, APP_COMPONENT} from 'angular2/src/core/application_tokens';
import {ApplicationRef} from 'angular2/src/core/application';
import {createNgZone} from 'angular2/src/core/application_common';
import {Serializer} from "angular2/src/web-workers/shared/serializer";
@ -87,9 +84,9 @@ function _injectorBindings(appComponentType, bus: WebWorkerMessageBus,
bestChangeDetection = JitChangeDetection;
}
return [
bind(appComponentTypeToken)
bind(APP_COMPONENT)
.toValue(appComponentType),
bind(appComponentRefPromiseToken)
bind(APP_COMPONENT_REF_PROMISE)
.toFactory(
(dynamicComponentLoader, injector) => {
@ -99,7 +96,7 @@ function _injectorBindings(appComponentType, bus: WebWorkerMessageBus,
},
[DynamicComponentLoader, Injector]),
bind(appComponentType).toFactory((ref) => ref.instance, [appComponentRefPromiseToken]),
bind(appComponentType).toFactory((ref) => ref.instance, [APP_COMPONENT_REF_PROMISE]),
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()),
[ExceptionHandler]),
Serializer,
@ -163,7 +160,7 @@ export function bootstrapWebWorkerCommon(
message["data"]["value"]);
var compRefToken = PromiseWrapper.wrap(() => {
try {
return appInjector.get(appComponentRefPromiseToken);
return appInjector.get(APP_COMPONENT_REF_PROMISE);
} catch (e) {
throw e;
}