Chromium Code Reviews| Index: client/dart.js |
| diff --git a/client/dart.js b/client/dart.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..df24d96a2510f0c1902476310fa89032063b9f33 |
| --- /dev/null |
| +++ b/client/dart.js |
| @@ -0,0 +1,26 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +// Bootstrap support for Dart scripts on the page as this script. |
| + |
| +if (!document.implementation.hasFeature('dart', '1.0')) { |
| + window.addEventListener("DOMContentLoaded", function (e) { |
| + // Fall back to compiled JS. |
|
danrubel
2012/01/20 21:20:36
Do we need a "is Dart available in this browser" c
vsm
2012/01/20 21:55:27
Line 7 is that check. Note, we will probably chan
|
| + var scripts = document.getElementsByTagName("script"); |
| + var length = scripts.length; |
| + for (var i = 0; i < length; ++i) { |
| + if (scripts[i].type == "application/dart") { |
| + var script = document.createElement('script'); |
| + // Remap foo.dart to foo.js. |
| + // TODO: |
| + // - Support in-browser compilation. |
| + // - Handle inline Dart scripts. |
| + if (scripts[i].src && scripts[i].src != '') { |
| + script.src = scripts[i].src + '.js'; |
| + document.body.appendChild(script); |
|
dgrove
2012/01/20 20:57:03
won't this break scripts that want to look at thei
vsm
2012/01/20 21:55:27
Modified to replace the original script.
On 2012/
|
| + } |
| + } |
| + } |
| + }, false); |
| +} |