Index: lib/boot.js |
diff --git a/lib/boot.js b/lib/boot.js |
index 3e794cdd0c4ef0ad7f4dab02c54a0e5859321327..15e43865616746767be633e7837d23667a306e44 100644 |
--- a/lib/boot.js |
+++ b/lib/boot.js |
@@ -100,24 +100,22 @@ |
} |
// Moves <polymer-elements> from imported documents into the top-level page. |
- function inlinePolymerElements(content, seen) { |
+ function inlinePolymerElements(content, ref, seen) { |
if (!seen) seen = {}; |
var links = content.querySelectorAll('link[rel="import"]'); |
+ for (var i = 0; i < links.length; i++) { |
+ var link = links[i].import; |
+ if (seen[link.href]) continue; |
+ seen[link.href] = link; |
+ inlinePolymerElements(link.content, ref, seen); |
+ } |
if (content != document) { // no need to do anything for the top-level page |
var elements = content.querySelectorAll('polymer-element'); |
- var ref = document.body.firstChild; |
- for (var i = 0; i < elements.length; ++i) { |
+ for (var i = 0; i < elements.length; i++) { |
document.body.insertBefore(elements[i], ref); |
} |
} |
- |
- for (var i = 0; i < links.length; i++) { |
- var link = links[i].import; |
- if (seen[link.href]) continue; |
- seen[link.href] = link; |
- inlinePolymerElements(link.content, seen); |
- } |
} |
// Creates a Dart program that imports [urls] and [mainUrl] and invokes the |
@@ -131,7 +129,7 @@ |
imports[urls.length] = 'import "package:polymer/polymer.dart" as polymer;'; |
imports[urls.length + 1 ] = 'import "' + mainUrl + '" as userMain;'; |
var firstArg = urls.length == 0 ? '[]' : |
- ('[\n "' + urls.join('",\n "') + '"\n ]'); |
+ ('[\n "' + urls.join('",\n "') + '"\n ]'); |
return (imports.join('\n') + |
'\n\nmain() {\n' + |
' polymer.initPolymer(' + firstArg + ', userMain.main);\n' + |
@@ -179,7 +177,8 @@ |
return; |
} |
alreadyRan = true; |
- inlinePolymerElements(document); |
+ var ref = document.body.children[0]; |
+ inlinePolymerElements(document, ref); |
mergeScripts(); |
if (!navigator.webkitStartDart()) { |
document.body.innerHTML = 'This build has expired. Please download a ' + |