Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#1142 closed bug (wontfix)

handle() should not iterate inherited members

Reported by: flamefork Owned by:
Priority: major Milestone: 1.1.3
Component: event Version: 1.1.2
Keywords: Cc:
Blocked by: Blocking:

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)) {
      ...
   }
}

Change History (2)

comment:1 Changed 13 years ago by flamefork

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

comment:2 Changed 13 years ago by brandon

Resolution: wontfix
Status: newclosed

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.