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

Unified Diff: lib/boot.js

Issue 22962005: Merge pull request #581 from kevmoo/polymer (Closed) Base URL: https://github.com/dart-lang/web-ui.git@polymer
Patch Set: Created 7 years, 4 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 | « example/todomvc/web/todo_row.html ('k') | lib/dwc.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ' +
« no previous file with comments | « example/todomvc/web/todo_row.html ('k') | lib/dwc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698