- From: David Bruant <bruant.d@gmail.com>
- Date: Sun, 20 Jul 2014 01:05:07 +0200
- To: Boris Zbarsky <bzbarsky@MIT.EDU>, Dirk Schulze <dschulze@adobe.com>
- CC: "public-script-coord@w3.org" <public-script-coord@w3.org>, Erik Arvidsson <arv@chromium.org>
Le 19/07/2014 18:01, Boris Zbarsky a écrit : > On 7/19/14, 9:23 AM, Dirk Schulze wrote: > >> Maybe this is enough and just needs to be evangelist? > > Enough for what? I mean, it's possible to write: > > Array.from(document.querySelectorAll("whatever")).map(someFunc) > > today in Firefox, but no other browser seems to support it so far. Easily polyfilled, though https://github.com/mathiasbynens/Array.from ES6 also has nice syntax to make an array: [...document.querySelectorAll("whatever")] (but that's syntax, so hard to polyfill, requires a transpiler of sort) > It's possible to do: > > Array.prototype.slice. > call(document.querySelectorAll("whatever")).map(someFunc) > > in all browsers, but the first reaction people have when they see that > is "WAT?". Can't say I blame them. With ArrayClass that becomes: > > document.querySelectorAll("whatever").map(someFunc) > > which is what people want out of this stuff anyway. Another option, which is the one I'll be using increasingly, is to do HTMLCollection.prototype._map = Array.prototype.map then, one can do: document.querySelectorAll("whatever")._map(someFunc) Close enough as far as I'm concerned and hopefully not stepping on future standards toes. David
Received on Saturday, 19 July 2014 23:05:38 UTC