Having a non-enumerable Array.prototype.contains may not beweb-compatible

Garrett Smith dhtmlkitchen at gmail.com
Tue Oct 7 13:21:48 PDT 2014


Old sites with old version of Mootools will have problems when trying
to use native Array.prototype.contains. Is that the only problem or is
there something else I'm missing?


On 10/7/14, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote:
> FYI: from a MooTools core developer:
> https://gist.github.com/fakedarren/28953b01e455078fb4f8
>


The article has a few issues. Array.prototype.forEach landed in
Mozilla before 2006, and there are still libraries that modify DOM
prototypes. Polymer, by the former Bindows author, is one.  Modifying
built-in Array.prototype for GP scripts was never a good idea.  And
the gist misses the big point that modifying objects that you don't
own, you risk issues with forwards compatibility. Here it is now, at
forward compatibility issue point. The ideas were bad at the time. I
criticized them pretty heavily around 2007 for these ideas and they
complained on my blog. Now, they are congratulating themselves on
their efforts, and blaming Microsoft for forcing them to make those
mistakes.


Mootools' contains be refactored and that's what the good folks at
this thread brought up. MooTools can do a conditional check with a
feature test, create a replacement alternative for their own methods,
and deprecate, for future removal, MooTools' custom
Array.prototype.contains in favor of something that is not
incompatible.


This situation reminds me of the W3C proposal for Event creation to
use `Event` constructor, regardless of Mootools already having defined
a global Event constructor for the web.

That w3c proposal was adopted and implemented, probably with compat
issues, seeing as MooTools has removed their Event for their new
global DOMEvent function, deprecated their global `Event` function,
kept it for backwards compatibility, and then removed it in a
subsequent release.


Their replacement's name "DOMEvent" starts with "DOM" and there is no
guarantee that the w3c won't define a new type of event called
DOMEvent (maybe to describe DOM Mutation). MooEvent is a more
intentional and a better name.

But anyway, MooTools, can with their Array.prototype.contains what
they did with their Event. Maybe with a better name or maybe using
another typeof approach than "rename".


jsfiddle.com
http://lists.w3.org/Archives/Public/public-script-coord/2011JulSep/0115.html
http://www.twitlonger.com/show/bd2994
-- 
Garrett
@xkit
ChordCycles.com
garretts.github.io


More information about the es-discuss mailing list