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

Side by Side Diff: pkg/browser/lib/dart.js

Issue 14790017: Workaround for 8455 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 if (navigator.webkitStartDart) { 6 if (navigator.webkitStartDart) {
7 if (!navigator.webkitStartDart()) { 7 if (!navigator.webkitStartDart()) {
8 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html'; 8 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html';
9 } 9 }
10 } else { 10 } else {
11 // TODO: 11 // TODO:
12 // - Support in-browser compilation. 12 // - Support in-browser compilation.
13 // - Handle inline Dart scripts. 13 // - Handle inline Dart scripts.
14 window.addEventListener("DOMContentLoaded", function (e) { 14 window.addEventListener("DOMContentLoaded", function (e) {
15 // Fall back to compiled JS. Run through all the scripts and 15 // Fall back to compiled JS. Run through all the scripts and
16 // replace them if they have a type that indicate that they source 16 // replace them if they have a type that indicate that they source
17 // in Dart code. 17 // in Dart code.
18 // 18 //
19 // <script type="application/dart" src="..."></script> 19 // <script type="application/dart" src="..."></script>
20 // 20 //
21 var scripts = document.getElementsByTagName("script"); 21 var scripts = document.getElementsByTagName("script");
22 var length = scripts.length; 22 var length = scripts.length;
23 for (var i = 0; i < length; ++i) { 23 for (var i = 0; i < length; ++i) {
24 if (scripts[i].type == "application/dart") { 24 if (scripts[i].type == "application/dart") {
25 // Remap foo.dart to foo.dart.js. 25 // Remap foo.dart to foo.dart.js.
26 if (scripts[i].src && scripts[i].src != '') { 26 if (scripts[i].src && scripts[i].src != '') {
27 var script = document.createElement('script'); 27 var script = document.createElement('script');
28 script.src = scripts[i].src.replace(/\.dart(?=\?|$)/, '.dart.js'); 28 script.src = scripts[i].src.replace(/\.dart(?=\?|$)/, '.dart.js');
29 var parent = scripts[i].parentNode; 29 var parent = scripts[i].parentNode;
30 // TODO(vsm): Find a solution for issue 8455 that works with more
31 // than one script.
32 document.currentScript = script;
30 parent.replaceChild(script, scripts[i]); 33 parent.replaceChild(script, scripts[i]);
31 } 34 }
32 } 35 }
33 } 36 }
34 }, false); 37 }, false);
35 } 38 }
36 39
37 // --------------------------------------------------------------------------- 40 // ---------------------------------------------------------------------------
38 // Experimental support for JS interoperability 41 // Experimental support for JS interoperability
39 // --------------------------------------------------------------------------- 42 // ---------------------------------------------------------------------------
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 var result = null; 243 var result = null;
241 var listener = function (e) { 244 var listener = function (e) {
242 result = JSON.parse(getPortSyncEventData(e)); 245 result = JSON.parse(getPortSyncEventData(e));
243 }; 246 };
244 window.addEventListener(source, listener, false); 247 window.addEventListener(source, listener, false);
245 dispatchEvent(target, [source, serialized]); 248 dispatchEvent(target, [source, serialized]);
246 window.removeEventListener(source, listener, false); 249 window.removeEventListener(source, listener, false);
247 return deserialize(result); 250 return deserialize(result);
248 } 251 }
249 })(); 252 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698