[whatwg] [URL] DOM API Feedback
Tab Atkins Jr.
jackalmage at gmail.com
Sun Nov 18 15:47:27 PST 2012
On Sun, Nov 18, 2012 at 3:17 PM, Anne van Kesteren <annevk at annevk.nl> wrote:
> On Sun, Nov 18, 2012 at 11:34 PM, David Bruant <bruant.d at gmail.com> wrote:
>> I feel the URLQuery object could be a regular object. Or maybe an ES6 Map.
>> If not an ES6 Map, maybe its API could be mapped exactly to ES6 Map. It
>> would increase interoperability.
>
> It cannot be a regular object because it modifies an underlying
> string. I suppose the same goes for ES6 Map. And URLQuery represents
> an ordered list of key-value pairs so I'm not sure how close it can
> be.
URLQuery is already *almost* duck-typed as a Map. It's only missing:
* the has() function (strictly unnecessary given the restriction that
values are all strings, but nearly free, and useful for API
consistency)
* the iteration functions keys(), values(), and items().
It would be nice if, as previously mentioned, you could do a bulk-set.
Just use the same meaning as the Map constructor, where it takes any
iterable, converts the keys and values to strings, and goes through it
in iteration order, adding each pair.
Even though it has magic behavior underneath, I think it should still
be possible to be a subclass of Map, which would be the best thing.
Then, the missing parts I described above would come for free.
~TJ
More information about the whatwg
mailing list