Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: pkg/polymer/lib/src/build/polyfill_injector.dart

Issue 27903006: Improves how to initialize polymer apps and fixes polymer build and linter to (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/polymer/lib/src/build/polyfill_injector.dart
diff --git a/pkg/polymer/lib/src/build/polyfill_injector.dart b/pkg/polymer/lib/src/build/polyfill_injector.dart
index 3bf7e7a671c28584c5099d5f711768e1df24eede..acc0d7185c9b80267f7f90dbeb760702bb20d085 100644
--- a/pkg/polymer/lib/src/build/polyfill_injector.dart
+++ b/pkg/polymer/lib/src/build/polyfill_injector.dart
@@ -36,6 +36,7 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
bool jsInteropFound = false;
bool customElementFound = false;
bool dartScriptTags = false;
+ bool dartLoaderTagFound = false;
for (var tag in document.queryAll('script')) {
var src = tag.attributes['src'];
@@ -47,6 +48,8 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
shadowDomFound = true;
} else if (_customElementJS.hasMatch(last)) {
customElementFound = true;
+ } else if (last == 'dart.js') {
+ dartLoaderTagFound = true;
}
}
@@ -62,7 +65,7 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
}
_addScript(urlSegment) {
- document.body.nodes.insert(0, parseFragment(
+ document.head.nodes.insert(0, parseFragment(
'<script src="packages/$urlSegment"></script>\n'));
}
@@ -72,10 +75,15 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
_addScript('custom_element/custom-elements.debug.js');
}
- // This polyfill needs to be the first one on the body
+ // This polyfill needs to be the first one on the head
// TODO(jmesserly): this is .debug to workaround issue 13046.
if (!shadowDomFound) _addScript('shadow_dom/shadow_dom.debug.js');
+ if (!dartLoaderTagFound) {
+ document.body.nodes.add(parseFragment(
+ '<script src="packages/browser/dart.js"></script>'));
+ }
+
transform.addOutput(
new Asset.fromString(transform.primaryInput.id, document.outerHtml));
});

Powered by Google App Engine
This is Rietveld 408576698