Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
3.4.0
-
None
-
None
-
iOS 7.1
iPhone 4 + Simulator
Description
The deviceready event never fires due to a JS error on iOS 7.1 with Cordova 3.4.x. This is the same issue as reported in CB-5488.
The console error/trace is:
[Error] TypeError: 'null' is not an object (evaluating 'document.body.appendChild')
createExecIframe (cordova.js, line 833)
iOSExec (cordova.js, line 1009)
getInfo (device.js, line 74)
(anonymous function) (device.js, line 48)
fire (cordova.js, line 750)
(anonymous function) (cordova.js, line 1195)
f (cordova.js, line 622)
fire (cordova.js, line 750)
(anonymous function) (cordova.js, line 1183)
onScriptLoadingComplete (cordova.js, line 1369)
scriptLoadedCallback (cordova.js, line 1386)
The fix that I've applied to cordova.js (from 3.4.1-0.1.0) is to replace lines 1627-1630.
Old:
window.cordova = require('cordova'); // file: src/scripts/bootstrap.js require('cordova/init');
New:
var documentBodyIntervalID = window.setInterval( function() { if ( null == document.body ) { return; } window.clearInterval( documentBodyIntervalID ); window.cordova = require('cordova'); // file: src/scripts/bootstrap.js require('cordova/init'); }, 100 );
I'm just checking document.body every 100ms to make sure that it's not null before triggering the rest of the Cordova script. I suspect it may have to do with Sencha Touch 2.3.1, but I can't guarantee it. I can provide an Xcode project if needed.
*Update*: I just realized that my fix is wreaking havoc on some plugins, as they load synchronously and expect cordova to be ready as soon as they load, which it isn't. Definitely need help on this one.
Attachments
Issue Links
- duplicates
-
CB-5488 deviceready event not firing with jQuery Mobile
- Closed