Bug Tracker

Ticket #13255 (closed bug: fixed)

Opened 23 months ago

Last modified 19 months ago

jQuery 2.0b1 and Cordova 2.3.0 cause "Uncaught TypeError: Cannot read property 'nodeType' of null".

Reported by: rahmadi_deswira@… Owned by: dmethvin
Priority: blocker Milestone: 2.0.1
Component: event Version: 2.0b1
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 follow-up: ↓ 2 Changed 22 months ago by dmethvin

  • Owner set to rahmadi_deswira@…
  • Status changed from new to pending

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:2 in reply to: ↑ 1 Changed 22 months ago by rahmadi_deswira@…

  • Status changed from pending to 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 22 months ago by dmethvin

  • Status changed from new to closed
  • Resolution set to notabug

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 20 months ago by spadarshut

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 20 months ago by dmethvin

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:6 Changed 20 months ago by spadarshut

I had the bug using v2.0.0b2, Date: 2013-3-1.

comment:7 Changed 20 months ago by dmethvin

comment:8 Changed 20 months ago by spadarshut

Yes, still breaks. Throws at line 4775:

if ( event.target.nodeType === 3 )

Checking for target first fixes the issue.

comment:9 Changed 20 months ago by dmethvin

  • Priority changed from undecided to blocker
  • Resolution notabug deleted
  • Status changed from closed to reopened
  • Component changed from unfiled to event
  • Milestone changed from None to 2.0

I just want to confirm: This is not a problem on real hardware, and only occurs on the emulator?

comment:10 Changed 20 months ago by spadarshut

No, it breaks on real devices too. Tested on android 2.3.

comment:11 Changed 19 months ago by spadarshut

I guess this bug fix didn't make it into 2.0?

comment:12 Changed 19 months ago by dmethvin

  • Status changed from reopened to open
  • Milestone changed from 2.0 to 2.0.1

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 19 months ago by dmethvin

  • Owner changed from rahmadi_deswira@… to dmethvin
  • Status changed from open to assigned

comment:14 Changed 19 months ago by jtblin

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 19 months ago by Dave Methvin

  • Status changed from assigned to closed
  • Resolution set to fixed

Fix #13255. Set a default event target for Cordova.

Changeset: 6b5391508e7354076a32375c7f536f8eb91195ee

Note: See TracTickets for help on using tickets.