Bug Tracker

Ticket #1142 (closed bug: wontfix)

Opened 2 years ago

Last modified 2 years ago

handle() should not iterate inherited members

Reported by: flamefork Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.1.3 Component: event
Version: 1.1.2 Keywords:
Cc: Needs: Review

Description

There is a bug when object.prototype has custom functions. Actually it was detected when jquery was used with json.js (it has Object.prototype.toJSONString() function) http://dev.jquery.com/browser/trunk/jquery/src/event/event.js#L164

164	        for ( var j in c ) {
165	            // Pass in a reference to the handler function itself
166	            // So that we can later remove it
167	            args[0].handler = c[j];
168	            args[0].data = c[j].data;
169
170	            if ( c[j].apply( this, args ) === false ) {
171	                event.preventDefault();
172	                event.stopPropagation();
173	                returnValue = false;
174	            }
175	        }

should be

for ( var j in c ) {
   if (c.hasOwnProperty(j)) {
      ...
   }
}

Attachments

Change History

Changed 2 years ago by flamefork

The same thing exists in $.ajax() params.

Changed 2 years ago by brandon

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

Changes to the Object prototype are not supported and should be avoided. Please search the list, fixes for json.js have been provided. http://groups.google.com/group/jquery-en

Note: See TracTickets for help on using tickets.