jquery/jquery — pull request #1140 by andrewplummer (2013-01-22 05:29:01+00:00)
Title: 1.9 stable sugar fix 265

Sugar (http://sugarjs.com/) adds methods to built-in prototypes.

Now, I realize that sentence alone will likely elicit a strong reaction, especially within the jQuery team. However, Sugar makes an argument that there is a safe way to augment JS natives by being safe, conservative in approach, tons of testing, and a few fundamental differences to Prototype (most of this is detailed here http://sugarjs.com/native). Sugar takes a certain stance, but I do see valid points to both sides of the argument.

However, I believe that the pull request I have submitted, lies *outside* this argument. The crux of the issue is that jQuery is checking for the property `namespace` on an object that is assumed to be a `jQuery.Event` but in fact may also be a string. When making this assumption it should do a type check to ensure that the object is an instance of `jQuery.Event` before assuming the property `namespace` on it.

I am anticipating a counterpoint that "it is reasonable for libs to assume "clean" prototypes" and I think there is a valid point to be made there. However I have my own counterpoints to that, and regardless this change can only serve to make jQuery more robust. Also I believe that if you are presuming a `namespace` property it is reasonable to assume it to be scoped to the object you have defined it on.

I am probably going to remove this method from Sugar anyway, 1. as an emergency fix on the assumption that this pr will take a while to be released even if it is accepted and 2. because it never fit into the lib very well anyway.

Thank you!

andrewplummer/Sugar/issues/265