Bug Tracker

Ticket #2789 (closed bug: wontfix)

Opened 8 months ago

Last modified 8 months ago

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

Reported by: mtrimpe Assigned to: anonymous
Type: bug Priority: minor
Milestone: 1.2.4 Component: event
Version: 1.2.3 Keywords: prototype
Cc: Needs: Review

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

Change History

Changed 8 months ago by flesler

  • status changed from new to closed
  • resolution set to wontfix

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

Note: See TracTickets for help on using tickets.