Opened 11 years ago
Closed 10 years ago
#13255 closed bug (fixed)
jQuery 2.0b1 and Cordova 2.3.0 cause "Uncaught TypeError: Cannot read property 'nodeType' of null".
Reported by: | Owned by: | dmethvin | |
---|---|---|---|
Priority: | blocker | Milestone: | 2.0.1 |
Component: | event | Version: | 2.0b1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery 2.0b1 and Cordova 2.3.0 cause "Uncaught TypeError: Cannot read property 'nodeType' of null".
Sorry I cannot provide test case on jsbin because the code requires cordova-2.3.0.js (BlackBerry version) and must run on Ripple emulator (Google Chrome extension), however the code is quite short:
<!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <script src="http://code.jquery.com/jquery-2.0.0b1.js"></script> <script src="cordova-2.3.0.js"></script> </head> <body> <script> // NOTE: Run on Ripple emulator 0.9.12 $(document).on("deviceready", function() { console.log("on deviceready"); }); </script> </body> </html>
Information: -jQuery version affected: 2.0b1. -Browser: Google Chrome 23.0.1271.97 + Ripple emulator 0.9.12 (extension). -OS: Windows 7 x64. -Other jQuery version tested: 1.9.0, runs fine (no error). -Ripple emulator settings: On "Devices" selection, please choose "BlackBerry Bold 9700".
Change History (15)
comment:1 follow-up: 2 Changed 11 years ago by
Owner: | set to rahmadi_deswira@… |
---|---|
Status: | new → pending |
comment:2 Changed 11 years ago by
Status: | pending → new |
---|
The error is on line 2760 of jquery-2.0.0b1.js. Here is the console output:
Uncaught TypeError: Cannot read property 'nodeType' of null...jquery-2.0.0b1.js:2760 ..jQuery.event.fix............................................jquery-2.0.0b1.js:2760 ..jQuery.event.dispatch.......................................jquery-2.0.0b1.js:2593 ..elemData.handle.............................................jquery-2.0.0b1.js:2316 ..Channel.fire................................................cordova-2.3.0.js:690 ..(anonymous function)........................................cordova-2.3.0.js:219
Note: I already tested the code on a real BlackBerry simulator OS 7.0 (not Ripple), no luck. Run fine on jQuery 1.9.0, but error on jQuery 2.0.0b1.
Please let me know if you need any other information. Thanks.
Replying to dmethvin:
Can you provide some more information about the failure? I'm not familiar with this emulator, and it could well be a bug in the emulator. What version of Blackberry OS does it run? Is there any other debugging information about the location of the error?
comment:3 Changed 11 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
If I'm reading the stack trace correctly, it looks like the cordova-2.3.0.js script is not setting an event target, but the real browser does. If that's the case it should be reported to them.
comment:4 Changed 10 years ago by
Need to reopen this bug.
The deviceready event has its target set to null and we are trying to check event.target.nodeType without checking if target actually exists as an object. Is it really necessary to attach an application file to prove that jquery is breaking in cordova? Checking for event.target && event.target.nodeType in jQuery.event.fix fixes the problem.
This doesn't break in a desktop browser because the deviceready event doesn't fire on desktop.
comment:5 Changed 10 years ago by
Did you try your test with beta 2, or with jquery-git2.js which is the latest 2.0 pre-beta? This sounds similar to something that we fixed long ago. It's hard to tell without code though.
comment:8 Changed 10 years ago by
Yes, still breaks. Throws at line 4775:
if ( event.target.nodeType === 3 )
Checking for target first fixes the issue.
comment:9 Changed 10 years ago by
Component: | unfiled → event |
---|---|
Milestone: | None → 2.0 |
Priority: | undecided → blocker |
Resolution: | notabug |
Status: | closed → reopened |
I just want to confirm: This is not a problem on real hardware, and only occurs on the emulator?
comment:12 Changed 10 years ago by
Milestone: | 2.0 → 2.0.1 |
---|---|
Status: | reopened → open |
Sorry, no it did not. I reopened it but didn't then mark it open so it didn't show up in the report.
comment:13 Changed 10 years ago by
Owner: | changed from rahmadi_deswira@… to dmethvin |
---|---|
Status: | open → assigned |
comment:14 Changed 10 years ago by
I confirm that this happens on iPhone and Android as well with cordova 2.5.0 version. It prevents the deviceready event from firing on mobiles with jquery 2.0.0 final. Adding the test to even.target on line 4757 does fix the issue i.e. if (event.target && event.target.nodeType === 3 ).
comment:15 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fix #13255. Set a default event target for Cordova.
Changeset: 6b5391508e7354076a32375c7f536f8eb91195ee
Can you provide some more information about the failure? I'm not familiar with this emulator, and it could well be a bug in the emulator. What version of Blackberry OS does it run? Is there any other debugging information about the location of the error?