@@ -26,6 +26,12 @@ class WebPlatform {
26
26
}
27
27
}
28
28
29
+ /**
30
+ * Because this code uses `strictStyling` for the polymer css shim, it is required to add the
31
+ * custom element’s name as an attribute on all DOM nodes in the shadowRoot (e.g. <span x-foo>).
32
+ *
33
+ * See http://www.polymer-project.org/docs/polymer/styling.html#strictstyling
34
+ */
29
35
String shimCss (String css, { String selector, String cssUrl }) {
30
36
if (! cssShimRequired) return css;
31
37
@@ -38,11 +44,9 @@ class WebPlatform {
38
44
// This adds an empty attribute with the name of the component tag onto
39
45
// each element in the shadow root.
40
46
//
41
- // Remove the try-catch once https://github.com/angular/angular.dart/issues/1189 is
42
- // fixed.
47
+ // TODO Remove the try-catch once https://github.com/angular/angular.dart/issues/1189 is fixed.
43
48
try {
44
- root.querySelectorAll ("*" )
45
- .forEach ((n) => n.attributes[selector] = "" );
49
+ root.querySelectorAll ("*" ).forEach ((n) => n.attributes[selector] = "" );
46
50
} catch (e, s) {
47
51
print ("WARNING: Failed to set up Shadow DOM shim for $selector .\n $e \n $s " );
48
52
}
@@ -66,14 +70,10 @@ class PlatformViewCache implements ViewCache {
66
70
ViewFactory fromHtml (String html, DirectiveMap directives) {
67
71
ViewFactory viewFactory;
68
72
69
- if (selector != null && selector != ""
70
- && platform.shadowDomShimRequired) {
71
-
72
- // By adding a comment with the tag name we ensure the template html is
73
- // unique per selector name when used as a key in the view factory
74
- // cache.
75
- viewFactory = viewFactoryCache.get (
76
- "<!-- Shimmed template for: <$selector > -->$html " );
73
+ if (selector != null && selector != "" && platform.shadowDomShimRequired) {
74
+ // By adding a comment with the tag name we ensure the template html is unique per selector
75
+ // name when used as a key in the view factory cache.
76
+ viewFactory = viewFactoryCache.get ("<!-- Shimmed template for: <$selector > -->$html " );
77
77
} else {
78
78
viewFactory = viewFactoryCache.get (html);
79
79
}
@@ -82,11 +82,9 @@ class PlatformViewCache implements ViewCache {
82
82
var div = new dom.DivElement ();
83
83
div.setInnerHtml (html, treeSanitizer: treeSanitizer);
84
84
85
- if (selector != null && selector != ""
86
- && platform.shadowDomShimRequired) {
87
- // This MUST happen before the compiler is called so that every dom
88
- // element gets touched before the compiler removes them for
89
- // transcluding directives like ng-if.
85
+ if (selector != null && selector != "" && platform.shadowDomShimRequired) {
86
+ // This MUST happen before the compiler is called so that every dom element gets touched
87
+ // before the compiler removes them for transcluding directives like `ng-if`
90
88
platform.shimShadowDom (div, selector);
91
89
}
92
90
0 commit comments