You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/06/02 01:52:27 UTC

js commit: At least on Android ICS WebView, when loading cordova.js asynchronously, it's possible to end up in a situation where the DOMContentLoaded has already fired, but the document.readyState is not "complete" (but still "interactive"). This patche

Updated Branches:
  refs/heads/master 95feb23c6 -> b9dcff467


At least on Android ICS WebView, when loading cordova.js asynchronously, it's possible to end up in a situation where the DOMContentLoaded has already fired, but the document.readyState is not "complete" (but still "interactive").  This patches this race condition.

Technically document.readyState === "interactive" is not exactly the same as when "DOMContentLoaded" triggers, but since the document is already done parsing (ref: http://dev.w3.org/html5/spec/the-end.html) it should be perfectly fine for Cordova's intents and purposes.  If you think this is too early, one could always defer onDOMContentLoaded.fire() to the subsequent "load" event if we find document.readyState == "interactive".

This may be a bit of an edge case, since the same version of Cordova (1.7.0) worked fine on Gingerbread, and most people don't load Cordova async, but this issue has been noted on other projects/browsers too (ref: http://bugs.jquery.com/ticket/10067).

Sorry for not including a test case; if you have a facility for reliably testing issues like this, let me know and I'll try to put it in.

Related: https://issues.apache.org/jira/browse/CB-499


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/b9dcff46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/b9dcff46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/b9dcff46

Branch: refs/heads/master
Commit: b9dcff46715b3d17a05f8724d0623e4af2dd8c7e
Parents: 95feb23
Author: Jarno Rantanen <ja...@jrw.fi>
Authored: Wed May 9 14:08:35 2012 +0300
Committer: Fil Maj <ma...@gmail.com>
Committed: Fri Jun 1 16:51:42 2012 -0700

----------------------------------------------------------------------
 lib/cordova.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/b9dcff46/lib/cordova.js
----------------------------------------------------------------------
diff --git a/lib/cordova.js b/lib/cordova.js
index 5eedc3a..32daed3 100644
--- a/lib/cordova.js
+++ b/lib/cordova.js
@@ -6,7 +6,7 @@ var channel = require('cordova/channel');
 document.addEventListener('DOMContentLoaded', function() {
     channel.onDOMContentLoaded.fire();
 }, false);
-if (document.readyState == 'complete') {
+if (document.readyState == 'complete' || document.readyState == 'interactive') {
     channel.onDOMContentLoaded.fire();
 }