On Thu, Oct 2, 2014 at 2:24 PM, Philip Chee <philip.c...@gmail.com> wrote:
> On 02/10/2014 17:30, David Rajchenbach-Teller wrote: > > On 02/10/14 10:49, James Graham wrote: > >> Unfortunately js libraries aren't like web browsers; you can't just ship > >> a new version and upgrade all existing users in a matter of weeks. > >> Instead usage of the broken versions may continue for years, depending > >> on the popularity of the library, how long it had been broken for, and > >> so on. > > > Is there even a solution to that problem? Could, say, > > `Array.prototype.contains` be instantiated lazily when called and only > > if no `Array.prototype.contains` has been defined by web code? > See this es-discuss thread for proposed solutions: http://esdiscuss.org/topic/array-prototype-contains-solutions bz pointed out that some web API additions are specified using the second of Domenic's proposals. > > I would have expected that their polyfill would be smart enough to > notice a ES7 compliant A.p.contains() and defer to it. > That's a very optimistisc expectation, unfortunately. It also doesn't fully work: code that expects the MooTools Array.prototype.contains, which is slightly different from the proposed standardized one, might simply not work with the latter. This case isn't really about whether the MooTools Array.prototype.contains is spec-compliant: the specific issue is that MooTools installs its Array.prototype extensions simply by setting them as value properties: Array.prototype.contains = function ... (or at least using code to that effect, bz lays it all out in bug 1075059[1]) Now, the ES7 version would be non-enumerable. Because of some fairly amazing details of how MooTools initialization works, that causes Array.prototype.contains to not get copied over to a collection class called "Elements". Again, see [1] for details. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1075059 _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform