refactor(compiler): various cleanups

- use `$implicit` variable value correctly
- handle `ng-non-bindable` correctly
- add some more assertions to `TemplateCompiler`
- make `CompiledTemplate` const
- fix default value for `@Directive.moduleId`
- add new compiler to application bindings

BREAKING CHANGE:
- `Compiler.compileInHost` and all methods of `DynamicComponentLoader` don’t take `Binding` any more, only `Type`s. This is in preparation for the new compiler which does not support this.

Part of #3605

Closes #4346
This commit is contained in:
Tobias Bosch
2015-09-18 10:33:23 -07:00
parent bffa2cb59b
commit 7470ad1bd1
29 changed files with 493 additions and 285 deletions

View File

@ -42,6 +42,8 @@ const IMPORT_ABS_MODULE_NAME_WITH_IMPORT =
export function main() {
describe('StyleCompiler', () => {
var xhr: SpyXHR;
var typeMeta;
beforeEachBindings(() => {
xhr = <any>new SpyXHR();
return [TEST_BINDINGS, bind(XHR).toValue(xhr)];
@ -49,16 +51,10 @@ export function main() {
var compiler: StyleCompiler;
beforeEach(inject([StyleCompiler], (_compiler) => { compiler = _compiler; }));
function comp(styles: string[], styleAbsUrls: string[], encapsulation: ViewEncapsulation):
CompileDirectiveMetadata {
return CompileDirectiveMetadata.create({
type: new CompileTypeMetadata({id: 23, moduleId: 'someUrl'}),
template: new CompileTemplateMetadata(
{styles: styles, styleUrls: styleAbsUrls, encapsulation: encapsulation})
});
}
beforeEach(inject([StyleCompiler], (_compiler) => {
typeMeta = new CompileTypeMetadata({id: 23, moduleId: 'someUrl'});
compiler = _compiler;
}));
describe('compileComponentRuntime', () => {
var xhrUrlResults;
@ -84,7 +80,9 @@ export function main() {
}
return PromiseWrapper.resolve(response);
});
return compiler.compileComponentRuntime(comp(styles, styleAbsUrls, encapsulation));
return compiler.compileComponentRuntime(
typeMeta, new CompileTemplateMetadata(
{styles: styles, styleUrls: styleAbsUrls, encapsulation: encapsulation}));
}
describe('no shim', () => {
@ -199,8 +197,9 @@ export function main() {
describe('compileComponentCodeGen', () => {
function compile(styles: string[], styleAbsUrls: string[], encapsulation: ViewEncapsulation):
Promise<string[]> {
var sourceExpression =
compiler.compileComponentCodeGen(comp(styles, styleAbsUrls, encapsulation));
var sourceExpression = compiler.compileComponentCodeGen(
typeMeta, new CompileTemplateMetadata(
{styles: styles, styleUrls: styleAbsUrls, encapsulation: encapsulation}));
var sourceWithImports = testableExpression(sourceExpression).getSourceWithImports();
return evalModule(sourceWithImports.source, sourceWithImports.imports, null);
};