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

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

Issue 676313004: fix bug where dart_support.js could get included above platform.js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: update pubspec/changelog Created 6 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
« no previous file with comments | « pkg/polymer/CHANGELOG.md ('k') | pkg/polymer/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2001facd9eeee480d6ef7e44f2d9cc5cd27d2082..2dc3b326f143c6f8022e67e3ee26d0eebf3dc7fa 100644
--- a/pkg/polymer/lib/src/build/polyfill_injector.dart
+++ b/pkg/polymer/lib/src/build/polyfill_injector.dart
@@ -38,7 +38,7 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
detailsUri: 'http://goo.gl/5HPeuP');
return readPrimaryAsHtml(transform, logger).then((document) {
bool dartSupportFound = false;
- bool platformJsFound = false;
+ Element platformJs;
Element dartJs;
final dartScripts = <Element>[];
@@ -47,7 +47,7 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
if (src != null) {
var last = src.split('/').last;
if (_platformJS.hasMatch(last)) {
- platformJsFound = true;
+ platformJs = tag;
} else if (_dartSupportJS.hasMatch(last)) {
dartSupportFound = true;
} else if (last == 'dart.js') {
@@ -97,10 +97,24 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
'<script src="packages/$urlSegment"></script>\n'));
}
- var suffix = options.releaseMode ? '.js' : '.concat.js';
- if (!dartSupportFound) _addScriptFirst('web_components/dart_support.js');
- // platform.js should come before all other scripts.
- if (!platformJsFound && options.injectPlatformJs) {
+ // Inserts dart_support.js either at the top of the document or directly
+ // after platform.js if it exists.
+ if (!dartSupportFound) {
+ if (platformJs == null) {
+ _addScriptFirst('web_components/dart_support.js');
+ } else {
+ var parentsNodes = platformJs.parentNode.nodes;
+ parentsNodes.insert(
+ parentsNodes.indexOf(platformJs) + 1,
+ parseFragment(
+ '\n<script src="packages/web_components/dart_support.js">'
+ '</script>'));
+ }
+ }
+
+ // By default platform.js should come before all other scripts.
+ if (platformJs == null && options.injectPlatformJs) {
+ var suffix = options.releaseMode ? '.js' : '.concat.js';
_addScriptFirst('web_components/platform$suffix');
}
« no previous file with comments | « pkg/polymer/CHANGELOG.md ('k') | pkg/polymer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698