diff --git a/modules/angular2/src/core/compiler/template_compiler.ts b/modules/angular2/src/core/compiler/template_compiler.ts index 0144b9df03..7e187d0800 100644 --- a/modules/angular2/src/core/compiler/template_compiler.ts +++ b/modules/angular2/src/core/compiler/template_compiler.ts @@ -56,28 +56,22 @@ export class TemplateCompiler { // For non components there is nothing to be normalized yet. return PromiseWrapper.resolve(directive); } - var normalizedTemplatePromise; - if (directive.isComponent) { - normalizedTemplatePromise = - this._templateNormalizer.normalizeTemplate(directive.type, directive.template); - } else { - normalizedTemplatePromise = PromiseWrapper.resolve(null); - } - return normalizedTemplatePromise.then( - (normalizedTemplate) => new CompileDirectiveMetadata({ - type: directive.type, - isComponent: directive.isComponent, - dynamicLoadable: directive.dynamicLoadable, - selector: directive.selector, - exportAs: directive.exportAs, - changeDetection: directive.changeDetection, - inputs: directive.inputs, - outputs: directive.outputs, - hostListeners: directive.hostListeners, - hostProperties: directive.hostProperties, - hostAttributes: directive.hostAttributes, - lifecycleHooks: directive.lifecycleHooks, template: normalizedTemplate - })); + + return this._templateNormalizer.normalizeTemplate(directive.type, directive.template) + .then((normalizedTemplate: CompileTemplateMetadata) => new CompileDirectiveMetadata({ + type: directive.type, + isComponent: directive.isComponent, + dynamicLoadable: directive.dynamicLoadable, + selector: directive.selector, + exportAs: directive.exportAs, + changeDetection: directive.changeDetection, + inputs: directive.inputs, + outputs: directive.outputs, + hostListeners: directive.hostListeners, + hostProperties: directive.hostProperties, + hostAttributes: directive.hostAttributes, + lifecycleHooks: directive.lifecycleHooks, template: normalizedTemplate + })); } compileHostComponentRuntime(type: Type): Promise { diff --git a/modules/angular2/src/core/compiler/template_normalizer.ts b/modules/angular2/src/core/compiler/template_normalizer.ts index 05970cf1b4..9ad9a7b0fb 100644 --- a/modules/angular2/src/core/compiler/template_normalizer.ts +++ b/modules/angular2/src/core/compiler/template_normalizer.ts @@ -59,11 +59,13 @@ export class TemplateNormalizer { .concat(templateMeta.styleUrls.map( url => this._urlResolver.resolve(directiveType.moduleUrl, url))); allStyleAbsUrls = ListWrapper.filter(allStyleAbsUrls, isStyleUrlResolvable); + var allResolvedStyles = allStyles.map(style => { var styleWithImports = extractStyleUrls(this._urlResolver, templateAbsUrl, style); styleWithImports.styleUrls.forEach(styleUrl => allStyleAbsUrls.push(styleUrl)); return styleWithImports.style; }); + var encapsulation = templateMeta.encapsulation; if (encapsulation === ViewEncapsulation.Emulated && allResolvedStyles.length === 0 && allStyleAbsUrls.length === 0) {