Skip to main content

Bug Tracker

Side navigation

#12660 closed bug (notabug)

Opened October 05, 2012 01:53PM UTC

Closed October 05, 2012 04:27PM UTC

Animations raises TypeError when Object is prototyped.

Reported by: ecoirier@olfeo.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:
Description

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

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

animations such as fadeOut raise an exception :

#!js
$("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
DOMContentLoaded
Attachments (0)
Change History (4)

Changed October 05, 2012 01:56PM UTC by ecoirier@olfeo.com comment:1

See example here : http://jsfiddle.net/ZH262/

Changed October 05, 2012 02:13PM UTC by Christian Meixner <christian.meixner@bippesbrandao.de> comment:2

Do not modify Object.prototype!

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

jQuery does not support that.

Changed October 05, 2012 03:53PM UTC by anonymous comment:3

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 ?

Changed October 05, 2012 04:27PM UTC by scottgonzalez comment:4

resolution: → notabug
status: newclosed