Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#9941 closed bug (invalid)

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

Reported by: [email protected] Owned by: [email protected]
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!

Change History (13)

comment:1 Changed 10 years ago by Rick Waldron

Component: unfiledevent
Owner: set to Rick Waldron
Priority: undecidedlow
Status: newassigned

comment:2 Changed 10 years ago by dmethvin

Owner: changed from Rick Waldron to [email protected]
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?

comment:3 in reply to:  2 Changed 10 years ago by [email protected]

Status: pendingnew

Replying to 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:

http://farm7.static.flickr.com/6206/6127916771_7649216fc1.jpg

comment:4 Changed 10 years ago by Rick Waldron

Milestone: None1.7
Owner: changed from [email protected] to Rick Waldron
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.

comment:5 Changed 10 years ago by dmethvin

Owner: changed from Rick Waldron to [email protected]
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?

comment:6 in reply to:  5 Changed 10 years ago by [email protected]

Status: pendingnew

Replying to 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:

http://farm7.static.flickr.com/6163/6172430114_ef10fd5b3f.jpg

comment:7 Changed 10 years ago by dmethvin

Status: newpending

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

comment:8 Changed 10 years ago by [email protected]

Status: pendingnew

dmethvin,

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

See here:

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

Thanks

comment:9 Changed 10 years ago by Rick Waldron

Owner: changed from [email protected] to Rick Waldron
Status: newassigned

comment:10 Changed 10 years ago by dmethvin

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.

comment:11 Changed 10 years ago by dmethvin

Owner: changed from Rick Waldron to [email protected]
Status: assignedpending

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

comment:12 Changed 10 years ago by dmethvin

Milestone: 1.71.next

comment:13 Changed 10 years ago by trac-o-bot

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!

Note: See TracTickets for help on using tickets.