| 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 // TODO: remove hasFeature clause once fully migrated to webkitStartDart. | |
| 8 if (navigator.webkitStartDart) { | 7 if (navigator.webkitStartDart) { |
| 9 navigator.webkitStartDart(); | 8 navigator.webkitStartDart(); |
| 10 } else if (!document.implementation.hasFeature('dart', '1.0')) { | 9 } else { |
| 11 window.addEventListener("DOMContentLoaded", function (e) { | 10 window.addEventListener("DOMContentLoaded", function (e) { |
| 12 // Fall back to compiled JS. | 11 // Fall back to compiled JS. |
| 13 var scripts = document.getElementsByTagName("script"); | 12 var scripts = document.getElementsByTagName("script"); |
| 14 var length = scripts.length; | 13 var length = scripts.length; |
| 15 for (var i = 0; i < length; ++i) { | 14 for (var i = 0; i < length; ++i) { |
| 16 if (scripts[i].type == "application/dart") { | 15 if (scripts[i].type == "application/dart") { |
| 17 // Remap foo.dart to foo.js. | 16 // Remap foo.dart to foo.js. |
| 18 // TODO: | 17 // TODO: |
| 19 // - Support in-browser compilation. | 18 // - Support in-browser compilation. |
| 20 // - Handle inline Dart scripts. | 19 // - Handle inline Dart scripts. |
| 21 if (scripts[i].src && scripts[i].src != '') { | 20 if (scripts[i].src && scripts[i].src != '') { |
| 22 var script = document.createElement('script'); | 21 var script = document.createElement('script'); |
| 23 script.src = scripts[i].src + '.js'; | 22 script.src = scripts[i].src + '.js'; |
| 24 var parent = scripts[i].parentNode; | 23 var parent = scripts[i].parentNode; |
| 25 parent.replaceChild(script, scripts[i]); | 24 parent.replaceChild(script, scripts[i]); |
| 26 } | 25 } |
| 27 } | 26 } |
| 28 } | 27 } |
| 29 }, false); | 28 }, false); |
| 30 } | 29 } |
| OLD | NEW |