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

Unified Diff: lib/src/emitters.dart

Issue 20863002: Introduce boot.js: this finally makes it possible to load and run Todomvc (Closed) Base URL: git@github.com:dart-lang/web-ui.git@master
Patch Set: Created 7 years, 5 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 | « lib/polymer_element.dart ('k') | lib/src/html_css_fixup.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/emitters.dart
diff --git a/lib/src/emitters.dart b/lib/src/emitters.dart
index 34d0d8686780a4d2537c7f7e9ba5c4c940c6866e..5381140eec5a6439e1df8ae21cba44c70f6cca61 100644
--- a/lib/src/emitters.dart
+++ b/lib/src/emitters.dart
@@ -248,7 +248,8 @@ CodePrinter generateBootstrapCode(
var printer = new CodePrinter(0)
..addLine('library app_bootstrap;')
..addLine('')
- ..addLine("import 'package:polymer/polymer.dart' as polymer;");
+ ..addLine("import 'package:polymer/polymer.dart';")
+ ..addLine("import 'dart:mirrors' show currentMirrorSystem;");
if (userMainInfo.userCode != null) {
printer..addLine('')
@@ -256,30 +257,36 @@ CodePrinter generateBootstrapCode(
"as userMain;\n");
}
+ int i = 0;
for (var c in global.components.values) {
if (c.hasConflict) continue;
- printer.addLine("import '${pathMapper.importUrlFor(info, c)}';");
+ printer.addLine("import '${pathMapper.importUrlFor(info, c)}' as i$i;");
+ i++;
}
printer..addLine('')
..addLine('void main() {')
- ..indent += 1;
-
- if (userMainInfo.userCode != null) printer.addLine('userMain.main();');
+ ..indent += 1
+ ..addLine("initPolymer([")
+ ..indent += 2;
for (var c in global.components.values) {
if (c.hasConflict) continue;
var tagName = escapeDartString(c.tagName);
var cssMapExpression = createCssSelectorsExpression(c,
CssPolyfillKind.of(options, c));
- printer
- ..addLine("polymer.setScopedCss('$tagName', $cssMapExpression);")
- ..addLine("polymer.registerPolymerElement("
- "'$tagName', () => new ${c.className}());");
+ printer.addLine("'${pathMapper.importUrlFor(info, c)}',");
}
return printer
..indent -= 1
+ ..addLine('],')
+ ..addLine(userMainInfo.userCode != null ? 'userMain.main,' : '() {},')
+ ..addLine(
+ "currentMirrorSystem().findLibrary(const Symbol('app_bootstrap'))")
+ ..indent += 2
+ ..addLine(".first.uri.toString());")
+ ..indent -= 4
..addLine('}');
}
@@ -360,6 +367,7 @@ void emitImports(DartCodeInfo codeInfo, LibraryInfo info, PathMapper pathMapper,
}
final shadowDomJS = new RegExp(r'shadowdom\..*\.js', caseSensitive: false);
+final bootJS = new RegExp(r'.*/polymer/boot.js', caseSensitive: false);
/** Trim down the html for the main html page. */
void transformMainHtml(Document document, FileInfo fileInfo,
@@ -381,8 +389,12 @@ void transformMainHtml(Document document, FileInfo fileInfo,
}
if (tag.attributes['type'] == 'application/dart') {
tag.remove();
- } else if (src != null && rewriteUrls) {
- tag.attributes["src"] = pathMapper.transformUrl(filePath, src);
+ } else if (src != null) {
+ if (bootJS.hasMatch(src)) {
+ tag.remove();
+ } else if (rewriteUrls) {
+ tag.attributes["src"] = pathMapper.transformUrl(filePath, src);
+ }
}
}
« no previous file with comments | « lib/polymer_element.dart ('k') | lib/src/html_css_fixup.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698