W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2012

Re: [whatwg] [URL] DOM API Feedback

From: David Bruant <bruant.d@gmail.com>
Date: Mon, 19 Nov 2012 17:00:10 +0100
Message-ID: <50AA578A.5040702@gmail.com>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Cc: whatwg@lists.whatwg.org
Le 19/11/2012 14:38, Boris Zbarsky a écrit :
> On 11/19/12 2:36 AM, David Bruant wrote:
>> An ES6 proxy could do the trick here.
>
> But then it's not a Map at all, right?  It's a proxy for maybe a Map, 
> maybe something else.  In what sense would it be a Map at that point?
I initially suggested either objects or maps. ES6 proxy was a followup 
for the idea of objects.

>>> I suppose the same goes for ES6 Map.
>> As Tab suggested, a Map subclass could certainly work
>
> How close are "subclasses" to not being vaporware (both in spec and 
> implementation terms)?
I don't understand what you mean by vaporware. ES6 Maps are a reality in 
Firefox and Chrome (behind a flag for the latter). Subclassing of ES6 
maps will be possible as soon as ES6 classes do (which I admit are still 
unimplemented)... well... it's actually possible today with __proto__ I 
guess.


> Speccing things in terms of vaporware makes them pretty hard to 
> implement in actual implementations...  Doesn't mean we shouldn't do 
> it, but I'm a bit wary of it, in general.
It's still possible for the spec to define an API that maps (no pun) the 
ES6 Map API (and does some additional magic). For those who'd care 
enough, it'll be possible to make this object a map.
If not an ES6 map, the same API will be good enough to avoid API diversity.

>
>> The ordered part for objects wasn't true in ES5 (implementation specific
>> order), but is considered for ES6 [1] since all web engines do the same
>> order
>
> Except they don't.  Here's a trivial example:
>
>   var obj = {};
>   obj["2"] = 5;
>   obj["1"] = 0;
>
> which is handled differently by different UAs.  The "same order" bit 
> is only true for property names that don't look like array indices.  
> Per proposed spec you linked to, by the way, this will enumerate 
> properties in the order "1" followed by "2".
Interesting, I thought the proposal was meant to capture de facto 
standard. Did UAs converge for that behavior recently? More 
specifically, what does IE9 do? (I guess oldIE are the ones diverging 
from the others?)


> Of course nothing really stops pages from using url parameters whose 
> names look like array indices.  So if we want ordered here, we just 
> can't use a object to do it.
Indeed. I have to admit, I was also worried about __proto__ and 
__defineGetter__ too, because they could have ended up being sources of 
security issues.

If it's an ES6 map or interoperable API, that's fine by me.

David
Received on Monday, 19 November 2012 16:18:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:11 GMT