
committed by
Misko Hevery

parent
9982520a23
commit
03793d0714
2
modules/angular2/src/core/application.js
vendored
2
modules/angular2/src/core/application.js
vendored
@ -99,7 +99,7 @@ function _injectorBindings(appComponentType): List<Binding> {
|
||||
UrlResolver,
|
||||
StyleUrlResolver,
|
||||
StyleInliner,
|
||||
CssProcessor,
|
||||
bind(CssProcessor).toFactory(() => new CssProcessor(null), []),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -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 <style> tags during the compilation.
|
||||
* Processes the <style> tags during the compilation:
|
||||
* - Apply any given transformers,
|
||||
* - Apply the shadow DOM strategy style step.
|
||||
*/
|
||||
export class CssProcessor {
|
||||
_transformers: List<CssTransformer>;
|
||||
|
||||
constructor(transformers: List<CssTransformer>) {
|
||||
this._transformers = transformers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a compile step to be added to the compiler pipeline.
|
||||
@ -24,22 +32,35 @@ export class CssProcessor {
|
||||
getCompileStep(cmpMetadata: DirectiveMetadata, shadowDomStrategy: ShadowDomStrategy,
|
||||
templateUrl: string) {
|
||||
var strategyStep = shadowDomStrategy.getStyleCompileStep(cmpMetadata, templateUrl);
|
||||
return new _CssProcessorStep(strategyStep);
|
||||
return new _CssProcessorStep(strategyStep, this._transformers);
|
||||
}
|
||||
}
|
||||
|
||||
export class CssTransformer {
|
||||
transform(styleElement) {};
|
||||
}
|
||||
|
||||
class _CssProcessorStep extends CompileStep {
|
||||
_strategyStep: CompileStep;
|
||||
_transformers: List<CssTransformer>;
|
||||
|
||||
constructor(strategyStep: CompileStep) {
|
||||
constructor(strategyStep: CompileStep, transformers: List<CssTransformer>) {
|
||||
super();
|
||||
this._strategyStep = strategyStep;
|
||||
this._transformers = transformers;
|
||||
}
|
||||
|
||||
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
|
||||
if (DOM.tagName(current.element) == 'STYLE') {
|
||||
current.ignoreBindings = true;
|
||||
|
||||
if (isPresent(this._transformers)) {
|
||||
var styleEl = current.element;
|
||||
for (var i = 0; i < this._transformers.length; i++) {
|
||||
this._transformers[i].transform(styleEl);
|
||||
}
|
||||
}
|
||||
|
||||
if (isPresent(this._strategyStep)) {
|
||||
this._strategyStep.process(parent, current, control);
|
||||
}
|
||||
|
Reference in New Issue
Block a user