Skip to content

Commit e1e4efe

Browse files
committed
doc(WebPlatform): improve the inline doc
1 parent cdde8c4 commit e1e4efe

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

lib/core_dom/web_platform.dart

+15-17
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class WebPlatform {
2626
}
2727
}
2828

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+
*/
2935
String shimCss(String css, { String selector, String cssUrl }) {
3036
if (!cssShimRequired) return css;
3137

@@ -38,11 +44,9 @@ class WebPlatform {
3844
// This adds an empty attribute with the name of the component tag onto
3945
// each element in the shadow root.
4046
//
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.
4348
try {
44-
root.querySelectorAll("*")
45-
.forEach((n) => n.attributes[selector] = "");
49+
root.querySelectorAll("*").forEach((n) => n.attributes[selector] = "");
4650
} catch (e, s) {
4751
print("WARNING: Failed to set up Shadow DOM shim for $selector.\n$e\n$s");
4852
}
@@ -66,14 +70,10 @@ class PlatformViewCache implements ViewCache {
6670
ViewFactory fromHtml(String html, DirectiveMap directives) {
6771
ViewFactory viewFactory;
6872

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");
7777
} else {
7878
viewFactory = viewFactoryCache.get(html);
7979
}
@@ -82,11 +82,9 @@ class PlatformViewCache implements ViewCache {
8282
var div = new dom.DivElement();
8383
div.setInnerHtml(html, treeSanitizer: treeSanitizer);
8484

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`
9088
platform.shimShadowDom(div, selector);
9189
}
9290

0 commit comments

Comments
 (0)