Bug Tracker

Opened 12 years ago

Closed 12 years ago

#2789 closed bug (wontfix)

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 ;
		...
	}
	...
}

Change History (1)

comment:1 Changed 12 years ago by flesler

Resolution: wontfix
Status: newclosed

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

Note: See TracTickets for help on using tickets.