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

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

Issue 584983002: don't move anything to body until first import (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/import_inliner.dart
diff --git a/pkg/polymer/lib/src/build/import_inliner.dart b/pkg/polymer/lib/src/build/import_inliner.dart
index 6054c189fe55467ff4972817a8ca4d2dae87bb3d..b6a973f3e4ea39775df00de740df11bf42eacb0e 100644
--- a/pkg/polymer/lib/src/build/import_inliner.dart
+++ b/pkg/polymer/lib/src/build/import_inliner.dart
@@ -62,7 +62,7 @@ class _HtmlInliner extends PolymerTransformer {
changed = new _UrlNormalizer(transform, docId, logger).visit(document)
|| changed;
-
+
experimentalBootstrap = document.querySelectorAll('link').any((link) =>
link.attributes['rel'] == 'import' &&
link.attributes['href'] == POLYMER_EXPERIMENTAL_HTML);
@@ -142,7 +142,9 @@ class _HtmlInliner extends PolymerTransformer {
/// To preserve the order of scripts with respect to inlined
/// link rel=import, we move both of those into the body before we do any
- /// inlining.
+ /// inlining. We do not start doing this until the first import is found
+ /// however, as some scripts do need to be ran in the head to work
+ /// properly (platform.js for instance).
///
/// Note: we do this for stylesheets as well to preserve ordering with
/// respect to eachother, because stylesheets can be pulled in transitively
@@ -152,11 +154,14 @@ class _HtmlInliner extends PolymerTransformer {
// Should we do the same? Alternatively could we inline head into head and
// body into body and avoid this whole thing?
void _moveHeadToBody(Document doc) {
+ var foundImport = false;
for (var node in doc.head.nodes.toList(growable: false)) {
if (node is! Element) continue;
var tag = node.localName;
var type = node.attributes['type'];
var rel = node.attributes['rel'];
+ if (tag == 'link' && rel == 'import') foundImport = true;
+ if (!foundImport) continue;
if (tag == 'style' || tag == 'script' &&
(type == null || type == TYPE_JS || type == TYPE_DART) ||
tag == 'link' && (rel == 'stylesheet' || rel == 'import')) {
« 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