@@ -32,7 +32,7 @@ class ShadowDomComponentFactory implements ComponentFactory {
32
32
33
33
ShadowDomComponentFactory (this ._expando, this ._config);
34
34
35
- final Map <_ComponentAssetKey , async.Future <dom.StyleElement >> _styleElementCache = {};
35
+ final Map <String , async.Future <dom.StyleElement >> _styleElementCache = {};
36
36
37
37
38
38
@@ -46,16 +46,8 @@ class ShadowDomComponentFactory implements ComponentFactory {
46
46
DirectiveMap directives = injector.getByKey (DIRECTIVE_MAP_KEY );
47
47
NgBaseCss baseCss = component.useNgBaseCss ? injector.getByKey (NG_BASE_CSS_KEY ) : null ;
48
48
// This is a bit of a hack since we are returning different type then we are.
49
- var componentFactory = new _ComponentFactory (node,
50
- ref.typeKey,
51
- component,
52
- injector.getByKey (NODE_TREE_SANITIZER_KEY ),
53
- injector.getByKey (WEB_PLATFORM_KEY ),
54
- injector.getByKey (COMPONENT_CSS_REWRITER_KEY ),
55
- _expando,
56
- baseCss,
57
- _styleElementCache,
58
- _config);
49
+ var componentFactory = new _ComponentFactory (node, ref.typeKey, component,
50
+ injector.getByKey (NODE_TREE_SANITIZER_KEY ), _expando, baseCss, _styleElementCache, _config);
59
51
var controller = componentFactory.call (injector, scope, viewCache, http, templateCache,
60
52
directives);
61
53
@@ -79,10 +71,7 @@ class _ComponentFactory implements Function {
79
71
final dom.NodeTreeSanitizer treeSanitizer;
80
72
final Expando _expando;
81
73
final NgBaseCss _baseCss;
82
- final Map <_ComponentAssetKey , async.Future <dom.StyleElement >>
83
- _styleElementCache;
84
- final ComponentCssRewriter componentCssRewriter;
85
- final WebPlatform platform;
74
+ final Map <String , async.Future <dom.StyleElement >> _styleElementCache;
86
75
final CompilerConfig _config;
87
76
88
77
dom.ShadowRoot shadowDom;
@@ -91,8 +80,7 @@ class _ComponentFactory implements Function {
91
80
var controller;
92
81
93
82
_ComponentFactory (this .element, this .typeKey, this .component, this .treeSanitizer,
94
- this .platform, this .componentCssRewriter, this ._expando,
95
- this ._baseCss, this ._styleElementCache, this ._config);
83
+ this ._expando, this ._baseCss, this ._styleElementCache, this ._config);
96
84
97
85
dynamic call (Injector injector, Scope scope,
98
86
ViewCache viewCache, Http http, TemplateCache templateCache,
@@ -111,57 +99,22 @@ class _ComponentFactory implements Function {
111
99
var cssUrls = _baseCss != null ?
112
100
([]..addAll (_baseCss.urls)..addAll (component.cssUrls)) :
113
101
component.cssUrls;
114
- var tag = element.tagName.toLowerCase ();
115
102
if (cssUrls.isNotEmpty) {
116
- cssFutures = cssUrls.map ((cssUrl) => _styleElementCache.putIfAbsent (
117
- new _ComponentAssetKey (tag, cssUrl), () =>
103
+ cssFutures = cssUrls.map ((cssUrl) => _styleElementCache.putIfAbsent (cssUrl, () =>
118
104
http.get (cssUrl, cache: templateCache)
119
105
.then ((resp) => resp.responseText,
120
106
onError: (e) => '/*\n $e \n */\n ' )
121
- .then ((String css) {
122
-
123
- // Shim CSS if required
124
- if (platform.cssShimRequired) {
125
- css = platform.shimCss (css, selector: tag, cssUrl: cssUrl);
126
- }
127
-
128
- // If a css rewriter is installed, run the css through a rewriter
129
- var styleElement = new dom.StyleElement ()
130
- ..appendText (componentCssRewriter (css, selector: tag,
131
- cssUrl: cssUrl));
132
-
133
- // ensure there are no invalid tags or modifications
134
- treeSanitizer.sanitizeTree (styleElement);
135
-
136
- // If the css shim is required, it means that scoping does not
137
- // work, and adding the style to the head of the document is
138
- // preferrable.
139
- if (platform.cssShimRequired) {
140
- dom.document.head.append (styleElement);
141
- }
142
-
143
- return styleElement;
144
- })
107
+ .then ((styleContent) => new dom.StyleElement ()..appendText (styleContent))
145
108
)).toList ();
146
109
} else {
147
110
cssFutures = [new async .Future .value (null )];
148
111
}
149
-
150
- var platformViewCache = new PlatformViewCache (viewCache, tag, platform);
151
-
152
- var viewFuture = ComponentFactory ._viewFuture (component, platformViewCache,
153
- directives);
154
-
112
+ var viewFuture = ComponentFactory ._viewFuture (component, viewCache, directives);
155
113
TemplateLoader templateLoader = new TemplateLoader (
156
114
async .Future .wait (cssFutures).then ((Iterable <dom.StyleElement > cssList) {
157
- // This prevents style duplication by only adding css to the shadow
158
- // root if there is a native implementation of shadow dom.
159
- if (! platform.cssShimRequired) {
160
- cssList.where ((styleElement) => styleElement != null )
161
- .forEach ((styleElement) {
162
- shadowDom.append (styleElement.clone (true ));
163
- });
164
- }
115
+ cssList
116
+ .where ((styleElement) => styleElement != null )
117
+ .forEach ((styleElement) => shadowDom.append (styleElement.clone (true )));
165
118
if (viewFuture != null ) {
166
119
return viewFuture.then ((ViewFactory viewFactory) {
167
120
return (! shadowScope.isAttached) ?
@@ -209,33 +162,3 @@ class _ComponentFactory implements Function {
209
162
return shadowInjector;
210
163
}
211
164
}
212
-
213
- class _ComponentAssetKey {
214
- final String tag;
215
- final String assetUrl;
216
-
217
- final String _key;
218
-
219
- _ComponentAssetKey (String tag, String assetUrl)
220
- : _key = "$tag |$assetUrl " ,
221
- this .tag = tag,
222
- this .assetUrl = assetUrl;
223
-
224
- @override
225
- String toString () => _key;
226
-
227
- @override
228
- int get hashCode => _key.hashCode;
229
-
230
- bool operator == (key) =>
231
- key is _ComponentAssetKey
232
- && tag == key.tag
233
- && assetUrl == key.assetUrl;
234
- }
235
-
236
- @Injectable ()
237
- class ComponentCssRewriter {
238
- String call (String css, { String selector, String cssUrl} ) {
239
- return css;
240
- }
241
- }
0 commit comments