diff --git a/modules/angular2/src/core/application.js b/modules/angular2/src/core/application.js index 61b479d12b..2a6e309359 100644 --- a/modules/angular2/src/core/application.js +++ b/modules/angular2/src/core/application.js @@ -99,7 +99,7 @@ function _injectorBindings(appComponentType): List { UrlResolver, StyleUrlResolver, StyleInliner, - CssProcessor, + bind(CssProcessor).toFactory(() => new CssProcessor(null), []), ]; } diff --git a/modules/angular2/src/core/compiler/css_processor.js b/modules/angular2/src/core/compiler/css_processor.js index 149b64804a..82a310e804 100644 --- a/modules/angular2/src/core/compiler/css_processor.js +++ b/modules/angular2/src/core/compiler/css_processor.js @@ -1,6 +1,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter'; import {isPresent} from 'angular2/src/facade/lang'; +import {List} from 'angular2/src/facade/collection'; import {CompileStep} from './pipeline/compile_step'; import {CompileElement} from './pipeline/compile_element'; @@ -10,9 +11,16 @@ import {ShadowDomStrategy} from './shadow_dom_strategy'; import {DirectiveMetadata} from './directive_metadata'; /** - * Processes the ')); @@ -44,13 +46,26 @@ export function main() { }); var strategy = new FakeShadowDomStrategy(compileStep); - var cssProcessor = new CssProcessor(); + var cssProcessor = new CssProcessor(null); var pipeline = createPipeline(cssProcessor, strategy, 'http://base'); var results = pipeline.process(el('
')); expect(processedEls.length).toEqual(1); expect(processedEls[0]).toBe(results[1].element); }); + + it('should apply the given transformers', () => { + var strategy = new FakeShadowDomStrategy(null); + var cssProcessor = new CssProcessor([ + new FakeCssTransformer('/*transformer1 */'), + new FakeCssTransformer('/*transformer2 */'), + ]); + + var pipeline = createPipeline(cssProcessor, strategy, 'http://base'); + var results = pipeline.process(el('
')); + + expect(results[1].element).toHaveText('/*transformer1 *//*transformer2 */'); + }); }); }); } @@ -79,4 +94,19 @@ class MockStep extends CompileStep { } } +class FakeCssTransformer extends CssTransformer { + _css: string; + + constructor(css: string) { + super(); + this._css = css; + } + + transform(styleEl) { + var cssText = DOM.getText(styleEl); + cssText += this._css; + DOM.setText(styleEl, cssText); + } +} + class SomeComponent {} diff --git a/modules/angular2/test/core/compiler/integration_spec.js b/modules/angular2/test/core/compiler/integration_spec.js index b6130bdd9f..586bc2702a 100644 --- a/modules/angular2/test/core/compiler/integration_spec.js +++ b/modules/angular2/test/core/compiler/integration_spec.js @@ -42,7 +42,7 @@ export function main() { tplResolver, new ComponentUrlMapper(), urlResolver, - new CssProcessor() + new CssProcessor(null) ); } diff --git a/modules/angular2/test/core/compiler/shadow_dom/shadow_dom_emulation_integration_spec.js b/modules/angular2/test/core/compiler/shadow_dom/shadow_dom_emulation_integration_spec.js index b938db6834..4aef354585 100644 --- a/modules/angular2/test/core/compiler/shadow_dom/shadow_dom_emulation_integration_spec.js +++ b/modules/angular2/test/core/compiler/shadow_dom/shadow_dom_emulation_integration_spec.js @@ -60,7 +60,7 @@ export function main() { tplResolver, new ComponentUrlMapper(), urlResolver, - new CssProcessor() + new CssProcessor(null) ); }); diff --git a/modules/angular2/test/directives/foreach_spec.js b/modules/angular2/test/directives/foreach_spec.js index 5a2281a98c..4d37c660d3 100644 --- a/modules/angular2/test/directives/foreach_spec.js +++ b/modules/angular2/test/directives/foreach_spec.js @@ -38,7 +38,7 @@ export function main() { tplResolver, new ComponentUrlMapper(), urlResolver, - new CssProcessor() + new CssProcessor(null) ); }); diff --git a/modules/angular2/test/directives/if_spec.js b/modules/angular2/test/directives/if_spec.js index 404b7c4437..8c56515c28 100644 --- a/modules/angular2/test/directives/if_spec.js +++ b/modules/angular2/test/directives/if_spec.js @@ -38,7 +38,7 @@ export function main() { tplResolver, new ComponentUrlMapper(), urlResolver, - new CssProcessor() + new CssProcessor(null) ); }); diff --git a/modules/angular2/test/directives/non_bindable_spec.js b/modules/angular2/test/directives/non_bindable_spec.js index ca6182283e..f42ccf0184 100644 --- a/modules/angular2/test/directives/non_bindable_spec.js +++ b/modules/angular2/test/directives/non_bindable_spec.js @@ -36,7 +36,7 @@ export function main() { tplResolver, new ComponentUrlMapper(), urlResolver, - new CssProcessor() + new CssProcessor(null) ); }); diff --git a/modules/angular2/test/directives/switch_spec.js b/modules/angular2/test/directives/switch_spec.js index 69cefebef9..e83a621f3c 100644 --- a/modules/angular2/test/directives/switch_spec.js +++ b/modules/angular2/test/directives/switch_spec.js @@ -33,7 +33,7 @@ export function main() { tplResolver, new ComponentUrlMapper(), urlResolver, - new CssProcessor() + new CssProcessor(null) ); }); diff --git a/modules/angular2/test/forms/integration_spec.js b/modules/angular2/test/forms/integration_spec.js index f7ddb68b1d..e5245963bd 100644 --- a/modules/angular2/test/forms/integration_spec.js +++ b/modules/angular2/test/forms/integration_spec.js @@ -39,7 +39,7 @@ export function main() { tplResolver, new ComponentUrlMapper(), urlResolver, - new CssProcessor() + new CssProcessor(null) ); tplResolver.setTemplate(componentType, new Template({ @@ -220,7 +220,7 @@ export function main() { }); }); }); - + describe("nested forms", () => { it("should init DOM with the given form object", (done) => { var form = new ControlGroup({ diff --git a/modules/benchmarks/src/compiler/compiler_benchmark.js b/modules/benchmarks/src/compiler/compiler_benchmark.js index 6cda00922b..280b57cf87 100644 --- a/modules/benchmarks/src/compiler/compiler_benchmark.js +++ b/modules/benchmarks/src/compiler/compiler_benchmark.js @@ -102,7 +102,7 @@ export function main() { templateResolver, new ComponentUrlMapper(), urlResolver, - new CssProcessor() + new CssProcessor(null) ); var templateNoBindings = createTemplateHtml('templateNoBindings', count); var templateWithBindings = createTemplateHtml('templateWithBindings', count); diff --git a/modules/benchmarks/src/naive_infinite_scroll/index.js b/modules/benchmarks/src/naive_infinite_scroll/index.js index 623a690811..9f99139900 100644 --- a/modules/benchmarks/src/naive_infinite_scroll/index.js +++ b/modules/benchmarks/src/naive_infinite_scroll/index.js @@ -282,7 +282,7 @@ export function setupReflectorForAngular() { }); reflector.registerType(CssProcessor, { - "factory": () => new CssProcessor(), + "factory": () => new CssProcessor(null), "parameters": [], "annotations": [] }); diff --git a/modules/benchmarks/src/tree/tree_benchmark.js b/modules/benchmarks/src/tree/tree_benchmark.js index cd0de5f438..3f7aaf0c48 100644 --- a/modules/benchmarks/src/tree/tree_benchmark.js +++ b/modules/benchmarks/src/tree/tree_benchmark.js @@ -172,7 +172,7 @@ function setupReflector() { }); reflector.registerType(CssProcessor, { - "factory": () => new CssProcessor(), + "factory": () => new CssProcessor(null), "parameters": [], "annotations": [] }); diff --git a/modules/examples/src/hello_world/index_static.js b/modules/examples/src/hello_world/index_static.js index 0c978512e4..f2c2a22ab3 100644 --- a/modules/examples/src/hello_world/index_static.js +++ b/modules/examples/src/hello_world/index_static.js @@ -151,7 +151,7 @@ function setup() { }); reflector.registerType(CssProcessor, { - "factory": () => new CssProcessor(), + "factory": () => new CssProcessor(null), "parameters": [], "annotations": [] });