Skip to main content

Bug Tracker

Side navigation

#2789 closed bug (wontfix)

Opened May 05, 2008 12:03PM UTC

Closed May 05, 2008 04:59PM UTC

jQuery.event.handle(event) also calls functions in Object.prototype

Reported by: mtrimpe Owned by:
Priority: minor Milestone: 1.2.4
Component: event Version: 1.2.3
Keywords: prototype Cc:
Blocked by: Blocking:
Description

I ran across a very obscure bug caused by a conflict between Prototype and jQuery...

The problem turned out to be that

1) Prototype extends Object.prototype with a function (e.g. prototypeExtend)

2) jQuery.event.handle calls jQuery.data which returns an Object with the data.

3) for ( var j in handlers ) loops over and calls all the functions in the Object returned by jQuery.data _AND_ all functions in Object.prototype.

In our case this meant prototypeExtend function was called with an <A> element and an event which resulted in copying the event properties including 'target' into the <A> element's properties resulting in each link opening a new window.

Below I've included a quick fix:

handle: function(event) {
	...
	for ( var j in handlers ) {
		// If the property is inherited from the super-class
		// then do nothing.
		if (handlers.constructor.prototype[j] == handlers[j])
			continue ;
		...
	}
	...
}
Attachments (0)
Change History (1)

Changed May 05, 2008 04:59PM UTC by flesler comment:1

resolution: → wontfix
status: newclosed

jQuery doesn't support code which extended the Object's prototype: #1488, #2721