#6125 closed bug (wontfix)
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: | ||
Blocked by: | Blocking: |
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 (2)
Change History (8)
Changed 13 years ago by
Changed 13 years ago by
Patched version of jQuery and test page that works correctly.
comment:1 follow-up: 2 Changed 12 years ago by
Priority: | → undecided |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Modifying Object.prototype is verboten.
comment:2 Changed 12 years ago by
Replying to snover:
Modifying Object.prototype is verboten.
Why? Is that not how the entire idea of inheritance works in JavaScript?
comment:3 Changed 12 years ago by
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.
comment:4 Changed 12 years ago by
Surely bulletproofing jQuery's code is a good idea, regardless of whether this is considered bad practice or not.
comment:5 Changed 12 years ago by
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.
comment:6 Changed 12 years ago by
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...)
Test case document