Bug Tracker

Ticket #6125 (closed bug: wontfix)

Opened 5 years ago

Last modified 4 years ago

Unfiltered for loop breaks animation in IE when a script extends the Object prototype

Reported by: willmorgan Owned by:
Priority: undecided Milestone: 1.4.2
Component: effects Version: 1.4.1
Keywords: Cc:
Blocking: Blocked by:

Description

I've added a function called size() to the Object prototype for getting the size of objects.

I noticed this broke animation in general, so commented out each module of my code until I found the source of the problem, which was the above.

I've got a fix, which is simply filtering the for loop on line 2724 where Sizzle.filter is defined:

if ( Expr.filter.hasOwnProperty( type ) ) {

As expected this doesn't cause a problem in Firefox ;)

Attachments

test.html Download (730 bytes) - added by willmorgan 5 years ago.
Test case document
6125.rar Download (42.5 KB) - added by willmorgan 5 years ago.
Patched version of jQuery and test page that works correctly.

Change History

Changed 5 years ago by willmorgan

Test case document

Changed 5 years ago by willmorgan

Patched version of jQuery and test page that works correctly.

comment:1 follow-up: ↓ 2 Changed 4 years ago by snover

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to wontfix

Modifying Object.prototype is verboten.

comment:2 in reply to: ↑ 1 Changed 4 years ago by willmorgan

Replying to snover:

Modifying Object.prototype is verboten.

Why? Is that not how the entire idea of inheritance works in JavaScript?

comment:3 Changed 4 years ago by ajpiano

No, it is not. It is fine to work with prototypes of various objects, but it is considered very poor practise to modify Object.protoype.

 http://erik.eae.net/archives/2005/06/06/22.13.54/

comment:4 Changed 4 years ago by willmorgan

Surely bulletproofing jQuery's code is a good idea, regardless of whether this is considered bad practice or not.

comment:5 Changed 4 years ago by ajpiano

This has come up before: #1529, #2721, #3785, #4121, #6132

Consistently jQuery's position has been, as Dave stated in #3785, that "Rewriting every for/in loop and object membership test is just too expensive." Until such time that the position should happen to change on that matter, jQuery will not work in pages that have modifications to Object.prototype.

Last edited 4 years ago by ajpiano (previous) (diff)

comment:6 Changed 4 years ago by willmorgan

I would agree that consistency is probably the best thing, though in fact, I've seen a few posts from John and Scott in the past saying that bulletproofing jQuery might be on the cards for future releases.

My £0.02 is that a widely used framework should be as portable and bulletproof as possible, and that there are arguments against extending the Object prototype and also not filtering for loops.. I've not seen any too much in depth discussion regarding the issue specific to jQuery, but if that's what the core team goes with, then fair enough.

Thanks for your time - I can imagine it's quite frustrating having closed many duplicates in the past hence the initial terseness (albeit 9 months later...)

Version 1, edited 4 years ago by willmorgan (previous) (next) (diff)
Note: See TracTickets for help on using tickets.