Skip to main content

Bug Tracker

Side navigation

#9941 closed bug (invalid)

Opened July 29, 2011 08:48PM UTC

Closed November 26, 2011 07:51AM UTC

Last modified March 14, 2012 10:49AM UTC

BB 5.0 - jQuery.removeEvent(elem, type, handle) throws java.lang.IllegalArgumentException

Reported by: suggsra@gmail.com Owned by: suggsra@gmail.com
Priority: low Milestone: 1.next
Component: event Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:
Description

I am using a Blackberry Simulator:

Blackberry 9550 v 5.0.0.713.

Using jquery 1.6.1

Essentially, I am calling

 $('selector').remove() 
on some divs to clear out the dom, and eventually this
 jQuery.removeEvent(elem, type, handle) 
causes the Blackberry to throw the IllegalArgumentException. The exception occurs during the
 elem.removeEventListener( type, handle, false ); 
execution when the 'handle' parameter is 'undefined'. Maybe all it needs is some null checks. Not a big deal because I have a work-around using some exception handling in the
 jQuery.cleanData() 
method.

Thanks!

Attachments (0)
Change History (13)

Changed July 29, 2011 09:00PM UTC by rwaldron comment:1

component: unfiledevent
owner: → rwaldron
priority: undecidedlow
status: newassigned

Changed September 08, 2011 08:22PM UTC by dmethvin comment:2

owner: rwaldronsuggsra@gmail.com
status: assignedpending

The error message sounds like a Java (not JavaScript) problem so it's a bit puzzling. I know it's a Blackberry but can you link us to a simple test case showing the problem?

Changed September 08, 2011 09:29PM UTC by suggsra@gmail.com comment:3

status: pendingnew

Replying to [comment:2 dmethvin]:

The error message sounds like a Java (not JavaScript) problem so it's a bit puzzling. I know it's a Blackberry but can you link us to a simple test case showing the problem?

It is a java problem, it appears to be an unhandled case of undefined parameters to the document.removeEventListener( type, handle, false ) of the blackberry browser, which is used by the jquery library. I'm asking for jquery to handle the exception just the same as it handles inconsistencies across other browsers.

Here is a jsfiddle showing the issue:

http://jsfiddle.net/eatF9/7/show/

Here is a screen shot of me viewing the error on a blackberry simulator:

[[Image(http://farm7.static.flickr.com/6206/6127916771_7649216fc1.jpg)]]

Changed September 09, 2011 04:10PM UTC by rwaldron comment:4

milestone: None1.7
owner: suggsra@gmail.comrwaldron
status: newassigned

After discussing this with the jQuery Mobile devs, I'm going to suggest we fix it, as BB5 still has a notable market presence.

Changed September 22, 2011 01:56AM UTC by dmethvin comment:5

owner: rwaldronsuggsra@gmail.com
status: assignedpending

That test case isn't an example of jQuery doing something wrong though. We need an example of jQuery code that would elicit that problem, not some non-jQuery code that clearly forces undefined as arguments. Can you provide a reduced test case?

Changed September 22, 2011 02:32PM UTC by suggsra@gmail.com comment:6

status: pendingnew

Replying to [comment:5 dmethvin]:

That test case isn't an example of jQuery doing something wrong though. We need an example of jQuery code that would elicit that problem, not some non-jQuery code that clearly forces undefined as arguments. Can you provide a reduced test case?

Sure,

http://jsfiddle.net/ricksuggs/eatF9/14/show/

FYI, here's my workaround that just catches the exception and moves on:

(function($){

	// XXX: rs - this method overrides jquery's default removeEvent method
	// created because there was an issue with clicking the dashboard
	// refresh button on BB 5.0, it threw a java.lang.IllegalArgumentException
	$.cleanData = function( elems ) {

		var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
			deleteExpando = jQuery.support.deleteExpando;

		try {

			for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
				if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
					continue;
				}
	
				id = elem[ jQuery.expando ];
	
				if ( id ) {
					data = cache[ id ] && cache[ id ][ internalKey ];
	
					if ( data && data.events ) {
						for ( var type in data.events ) {
							if ( special[ type ] ) {
								jQuery.event.remove( elem, type );
	
							// This is a shortcut to avoid jQuery.event.remove's overhead
							} else {
								jQuery.removeEvent( elem, type, data.handle );
							}
						}
	
						// Null the DOM reference to avoid IE6/7/8 leak (#7054)
						if ( data.handle ) {
							data.handle.elem = null;
						}
					}
	
					if ( deleteExpando ) {
						delete elem[ jQuery.expando ];
	
					} else if ( elem.removeAttribute ) {
						elem.removeAttribute( jQuery.expando );
					}
	
					delete cache[ id ];
				}
			}

		} catch (e) {
			// just let the IllegalArgumentExcpetion pass
		}
	};
})(jQuery);

Screenshot of device simulator throwing exception:

[[Image(http://farm7.static.flickr.com/6163/6172430114_ef10fd5b3f.jpg)]]

Changed September 26, 2011 10:00PM UTC by dmethvin comment:7

status: newpending

Can you check with the latest jQuery Mobile and see if it makes a difference?

Changed September 27, 2011 01:46PM UTC by suggsra@gmail.com comment:8

status: pendingnew

dmethvin,

the error still occurs with the latest version of jquery-mobile.

See here:

http://jsfiddle.net/ricksuggs/eatF9/15/show/

Thanks

Changed October 07, 2011 01:34AM UTC by rwaldron comment:9

owner: suggsra@gmail.comrwaldron
status: newassigned

Changed October 24, 2011 06:52PM UTC by dmethvin comment:10

I circled back around and cannot reproduce this in either 1.6.3 or 1.7b2. In Chrome and Firefox I put a conditional breakpoint on handle==null in removeEvent and it never hits.

@suggsra, could you see if the problem is still present in 1.7b2? Could you add some code to removeEvent and run it in your simulator to let us know what event type is causing the error? That might give us some more information.

Changed November 11, 2011 01:55PM UTC by dmethvin comment:11

owner: rwaldronsuggsra@gmail.com
status: assignedpending

We need some more information about this problem; see above.

Changed November 11, 2011 01:56PM UTC by dmethvin comment:12

milestone: 1.71.next

Changed November 26, 2011 07:51AM UTC by trac-o-bot comment:13

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!