OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Bootstrap support for Dart scripts on the page as this script. | 5 // Bootstrap support for Dart scripts on the page as this script. |
6 | 6 |
7 if (!document.implementation.hasFeature('dart', '1.0')) { | 7 if (navigator.webkitStartDart) { |
8 navigator.webkitStartDart(); | |
9 } else if (!document.implementation.hasFeature('dart', '1.0')) { | |
vsm
2012/02/01 15:35:08
Are you leaving hasFeature for staging purposes on
antonm
2012/02/01 17:07:00
Yes, hasFeature is only left for staging purposes
| |
8 window.addEventListener("DOMContentLoaded", function (e) { | 10 window.addEventListener("DOMContentLoaded", function (e) { |
9 // Fall back to compiled JS. | 11 // Fall back to compiled JS. |
10 var scripts = document.getElementsByTagName("script"); | 12 var scripts = document.getElementsByTagName("script"); |
11 var length = scripts.length; | 13 var length = scripts.length; |
12 for (var i = 0; i < length; ++i) { | 14 for (var i = 0; i < length; ++i) { |
13 if (scripts[i].type == "application/dart") { | 15 if (scripts[i].type == "application/dart") { |
14 // Remap foo.dart to foo.js. | 16 // Remap foo.dart to foo.js. |
15 // TODO: | 17 // TODO: |
16 // - Support in-browser compilation. | 18 // - Support in-browser compilation. |
17 // - Handle inline Dart scripts. | 19 // - Handle inline Dart scripts. |
18 if (scripts[i].src && scripts[i].src != '') { | 20 if (scripts[i].src && scripts[i].src != '') { |
19 var script = document.createElement('script'); | 21 var script = document.createElement('script'); |
20 script.src = scripts[i].src + '.js'; | 22 script.src = scripts[i].src + '.js'; |
21 var parent = scripts[i].parentNode; | 23 var parent = scripts[i].parentNode; |
22 parent.replaceChild(script, scripts[i]); | 24 parent.replaceChild(script, scripts[i]); |
23 } | 25 } |
24 } | 26 } |
25 } | 27 } |
26 }, false); | 28 }, false); |
27 } | 29 } |
OLD | NEW |