Bug Tracker

Opened 10 years ago

Closed 10 years ago

#12660 closed bug (notabug)

Animations raises TypeError when Object is prototyped.

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:


When adding a function in the prototype property of Object, ie :

if (!Object.noopFunc) {
        Object.prototype.noopFunc = function(e) {
                return "noOp";

animations such as fadeOut raise an exception :

$("div").fadeOut(500, someCallback);

Uncaught TypeError: Object function (e) {
    return "noOp";
} has no method 'concat' 

Here is a sample traceback :

(anonymous function) jquery-1.8.2.js:8595
jQuery.extend.each jquery-1.8.2.js:605
createTweens jquery-1.8.2.js:8594
Animation jquery-1.8.2.js:8683
jQuery.fn.extend.animate.doAnimation jquery-1.8.2.js:9005
jQuery.extend.dequeue jquery-1.8.2.js:1894
jQuery.fn.extend.queue jquery-1.8.2.js:1937
jQuery.extend.each jquery-1.8.2.js:611
jQuery.fn.jQuery.each jquery-1.8.2.js:241
jQuery.fn.extend.queue jquery-1.8.2.js:1930
jQuery.fn.extend.animate jquery-1.8.2.js:9015
jQuery.each.jQuery.fn.(anonymous function) jquery-1.8.2.js:9100
myNiceEffectFunction jQueryBugOnObjectProrotype.html:17
jQuery.Callbacks.fire jquery-1.8.2.js:974
jQuery.Callbacks.self.fireWith jquery-1.8.2.js:1082
jQuery.extend.ready jquery-1.8.2.js:406

Change History (4)

comment:2 Changed 10 years ago by Christian Meixner <[email protected]…>

Do not modify Object.prototype! Why? http://erik.eae.net/archives/2005/06/06/22.13.54/

jQuery does not support that.

comment:3 Changed 10 years ago by anonymous

I understand your point, and I have found a workaround using "Object.defineProperty". Is it as bad, or is it better, giving the fact that the defined properties look now like native methodes?

Anyway, for me there is either a bug in jQuery or something missing in the documentation stating that this practice doens't work with jQuery. Do you agree ?

comment:4 Changed 10 years ago by scottgonzalez

Resolution: notabug
Status: newclosed
Note: See TracTickets for help on using tickets.