
committed by
Misko Hevery

parent
9982520a23
commit
03793d0714
@ -302,7 +302,7 @@ class TestableCompiler extends Compiler {
|
||||
templateResolver,
|
||||
cmpUrlMapper,
|
||||
urlResolver,
|
||||
new CssProcessor());
|
||||
new CssProcessor(null));
|
||||
|
||||
this.steps = steps;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular2/test_lib';
|
||||
import {CssProcessor} from 'angular2/src/core/compiler/css_processor';
|
||||
import {CssProcessor, CssTransformer} from 'angular2/src/core/compiler/css_processor';
|
||||
|
||||
import {ShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy';
|
||||
|
||||
@ -8,6 +8,8 @@ import {CompileElement} from 'angular2/src/core/compiler/pipeline/compile_elemen
|
||||
import {CompileStep} from 'angular2/src/core/compiler/pipeline/compile_step';
|
||||
import {CompileControl} from 'angular2/src/core/compiler/pipeline/compile_control';
|
||||
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {Component} from 'angular2/src/core/annotations/annotations';
|
||||
|
||||
import {DirectiveMetadata} from 'angular2/src/core/compiler/directive_metadata';
|
||||
@ -28,7 +30,7 @@ export function main() {
|
||||
|
||||
it('it should set ignoreBindings to true for style elements', () => {
|
||||
var strategy = new FakeShadowDomStrategy(null);
|
||||
var cssProcessor = new CssProcessor();
|
||||
var cssProcessor = new CssProcessor(null);
|
||||
|
||||
var pipeline = createPipeline(cssProcessor, strategy, 'http://base');
|
||||
var results = pipeline.process(el('<div><style></style></div>'));
|
||||
@ -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('<div><style></style></div>'));
|
||||
|
||||
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('<div><style></style></div>'));
|
||||
|
||||
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 {}
|
||||
|
@ -42,7 +42,7 @@ export function main() {
|
||||
tplResolver,
|
||||
new ComponentUrlMapper(),
|
||||
urlResolver,
|
||||
new CssProcessor()
|
||||
new CssProcessor(null)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ export function main() {
|
||||
tplResolver,
|
||||
new ComponentUrlMapper(),
|
||||
urlResolver,
|
||||
new CssProcessor()
|
||||
new CssProcessor(null)
|
||||
);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user