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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 23201005: Revert revision 26149. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/third_party/dromaeo/generate_dart2js_tests.py ('k') | tools/testing/dart/browser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (revision 26171)
+++ sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (working copy)
@@ -857,7 +857,11 @@
return js.fun('oldIsolate', [
js('var isolateProperties = oldIsolate.${namer.isolatePropertiesName}'),
- js(r'isolateProperties.$currentScript = null'),
+ js(r'isolateProperties.$currentScript ='
+ 'typeof document == "object" ?'
+ '(document.currentScript ||'
+ 'document.scripts[document.scripts.length - 1]) :'
+ 'null'),
js('var isolatePrototype = oldIsolate.prototype'),
js('var str = "{\\n"'),
@@ -2968,47 +2972,24 @@
buffer.write(N);
}
addComment('BEGIN invoke [main].', buffer);
- // This code finds the currently executing script by listening to the
- // onload event of all script tags and getting the first script which
- // finishes. Since onload is called immediately after execution this should
- // not substantially change execution order.
buffer.write("""
-;(function (callback) {
- if (typeof document === 'undefined') {
- callback(null);
- return;
- }
- if (document.currentScript) {
- callback(document.currentScript);
- return;
- }
-
- var scripts = document.scripts;
- function onLoad() {
- for (var i = 0; i < scripts.length; ++i) {
- scripts[i].removeEventListener('load', onLoad, false);
+if (typeof document !== "undefined" && document.readyState !== "complete") {
+ document.addEventListener("readystatechange", function () {
+ if (document.readyState == "complete") {
+ if (typeof dartMainRunner === "function") {
+ dartMainRunner(function() { ${mainCall}; });
+ } else {
+ ${mainCall};
+ }
}
- callback(event.target);
- }
- for (var i = 0; i < scripts.length; ++i) {
- scripts[i].addEventListener('load', onLoad, false);
- }
-})(function(currentScript) {
- ${namer.isolateName}.${namer.isolatePropertiesName}.\$currentScript =
- currentScript;
-
- if (typeof console !== 'undefined' && typeof document !== 'undefined' &&
- document.readyState == "loading") {
- console.warn("Dart script executed synchronously, use <script src='" +
- currentScript.src + "' defer></scr" + "ipt> to execute after parsing " +
- "has completed. See also http://dartbug.com/12281.");
- }
+ }, false);
+} else {
if (typeof dartMainRunner === "function") {
dartMainRunner(function() { ${mainCall}; });
} else {
${mainCall};
}
-});
+}
""");
addComment('END invoke [main].', buffer);
}
« no previous file with comments | « samples/third_party/dromaeo/generate_dart2js_tests.py ('k') | tools/testing/dart/browser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698