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

Unified Diff: lib/src/emitters.dart

Issue 22928008: Refactor emitter in web-ui to make dart.js the last script, also cleanup tests (Closed) Base URL: git@github.com:dart-lang/web-ui.git@master
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
Index: lib/src/emitters.dart
diff --git a/lib/src/emitters.dart b/lib/src/emitters.dart
index b0cb58266c08a01e7b4b5dde74477a524121cf34..a92042e1bea886e108df1665e244f5556b695cb6 100644
--- a/lib/src/emitters.dart
+++ b/lib/src/emitters.dart
@@ -854,14 +854,15 @@ String _emitCreateHtml(Node node, Declarations statics) {
/** Trim down the html for the main html page. */
void transformMainHtml(Document document, FileInfo fileInfo,
- PathMapper pathMapper, bool hasCss, bool rewriteUrls, Messages messages) {
+ PathMapper pathMapper, bool hasCss, bool rewriteUrls, Messages messages,
+ String bootstrapOutName) {
var filePath = fileInfo.inputUrl.resolvedPath;
- bool dartLoaderFound = false;
+ var dartLoaderTag = null;
for (var tag in document.queryAll('script')) {
var src = tag.attributes['src'];
if (src != null && src.split('/').last == 'dart.js') {
- dartLoaderFound = true;
+ dartLoaderTag = tag;
}
if (tag.attributes['type'] == 'application/dart') {
tag.remove();
@@ -909,10 +910,18 @@ void transformMainHtml(Document document, FileInfo fileInfo,
document.head.nodes.insert(0, parseFragment(
'<style>template { display: none; }</style>'));
- if (!dartLoaderFound) {
+
+ var bootstrapScript = parseFragment(
+ '<script type="application/dart" src="$bootstrapOutName"></script>');
+ if (dartLoaderTag == null) {
+ document.body.nodes.add(bootstrapScript);
document.body.nodes.add(parseFragment(
'<script type="text/javascript" src="packages/browser/dart.js">'
'</script>\n'));
+ } else if (dartLoaderTag.parent != document.body) {
+ document.body.nodes.add(bootstrapScript);
+ } else {
+ document.body.nodes.insertBefore(bootstrapScript, dartLoaderTag);
}
// Insert the "auto-generated" comment after the doctype, otherwise IE will

Powered by Google App Engine
This is Rietveld 408576698