Skip to content

Commit

Permalink
fix(compiler): support string tokens with . inside.
Browse files Browse the repository at this point in the history
  • Loading branch information
tbosch committed Apr 21, 2016
1 parent 386cc5d commit cc86fee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/angular2/src/compiler/compile_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from 'angular2/src/core/change_detection/change_detection';
import {ViewEncapsulation, VIEW_ENCAPSULATION_VALUES} from 'angular2/src/core/metadata/view';
import {CssSelector} from 'angular2/src/compiler/selector';
import {splitAtColon} from './util';
import {splitAtColon, sanitizeIdentifier} from './util';
import {LifecycleHooks, LIFECYCLE_HOOKS_VALUES} from 'angular2/src/core/metadata/lifecycle_hooks';
import {getUrlScheme} from './url_resolver';

Expand Down Expand Up @@ -318,7 +318,9 @@ export class CompileTokenMetadata implements CompileMetadataWithIdentifier {
(isPresent(ak) && ak == token2.assetCacheKey);
}

get name(): string { return isPresent(this.value) ? this.value : this.identifier.name; }
get name(): string {
return isPresent(this.value) ? sanitizeIdentifier(this.value) : this.identifier.name;
}
}

export class CompileTokenMap<VALUE> {
Expand Down
11 changes: 11 additions & 0 deletions modules/angular2/test/core/linker/regression_integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ function declareTests(isJit: boolean) {
});
}));

it('should support providers with string token with a `.` in it',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
var token = 'a.b';
var tokenValue = 1;
createInjector(tcb, [provide(token, {useValue: tokenValue})])
.then((injector: Injector) => {
expect(injector.get(token)).toEqual(tokenValue);
async.done();
});
}));

it('should support providers with an anonymous function',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
var token = () => true;
Expand Down

0 comments on commit cc86fee

Please sign in to comment.