| Index: client/dart.js
|
| diff --git a/client/dart.js b/client/dart.js
|
| index d740c1fcd6940f2589a14ae38f86a267b056049c..d0899d1fa6ced6f5140c18f9b6f0e965e458f724 100644
|
| --- a/client/dart.js
|
| +++ b/client/dart.js
|
| @@ -3,27 +3,43 @@
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| // Bootstrap support for Dart scripts on the page as this script.
|
| -
|
| if (navigator.webkitStartDart) {
|
| navigator.webkitStartDart();
|
| } else {
|
| + // TODO:
|
| + // - Support in-browser compilation.
|
| + // - Handle inline Dart scripts.
|
| window.addEventListener("DOMContentLoaded", function (e) {
|
| - // Fall back to compiled JS.
|
| - var scripts = document.getElementsByTagName("script");
|
| - var length = scripts.length;
|
| - for (var i = 0; i < length; ++i) {
|
| - if (scripts[i].type == "application/dart") {
|
| - // Remap foo.dart to foo.js.
|
| - // TODO:
|
| - // - Support in-browser compilation.
|
| - // - Handle inline Dart scripts.
|
| - if (scripts[i].src && scripts[i].src != '') {
|
| - var script = document.createElement('script');
|
| + // Fall back to compiled JS. Run through all the scripts and
|
| + // replace them if they have a type that indicate that they source
|
| + // in Dart code.
|
| + //
|
| + // <script type="application/dart" src="<file>.dart"></script>
|
| + //
|
| + // If the script tag has a 'data-compiler' attribute set to
|
| + // dart2js then we use the dart2js generated file rather than the
|
| + // one produced by frog:
|
| + //
|
| + // <script ... data-compiler="dart2js"></script>
|
| + //
|
| + var scripts = document.getElementsByTagName("script");
|
| + var length = scripts.length;
|
| + for (var i = 0; i < length; ++i) {
|
| + if (scripts[i].type == "application/dart") {
|
| + // Remap foo.dart to foo.js or foo.js_ depending
|
| + // on the chosen compiler (frog or dart2js).
|
| + if (scripts[i].src && scripts[i].src != '') {
|
| + var script = document.createElement('script');
|
| + var compiler = scripts[i].getAttribute('data-compiler');
|
| + if (compiler == "dart2js") {
|
| + script.src = scripts[i].src + '.js_';
|
| + } else {
|
| script.src = scripts[i].src + '.js';
|
| - var parent = scripts[i].parentNode;
|
| - parent.replaceChild(script, scripts[i]);
|
| }
|
| + var parent = scripts[i].parentNode;
|
| + parent.replaceChild(script, scripts[i]);
|
| }
|
| }
|
| - }, false);
|
| + }
|
| + }, false);
|
| }
|
|
|