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

Re: [whatwg] [URL] DOM API Feedback

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sun, 18 Nov 2012 15:47:27 -0800
Message-ID: <CAAWBYDBRYvxa-uzBbp2AHYMMMPP2qe6GhEAYs1m8n+JiWKdnGA@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: whatwg <whatwg@whatwg.org>, David Bruant <bruant.d@gmail.com>
On Sun, Nov 18, 2012 at 3:17 PM, Anne van Kesteren <annevk@annevk.nl> wrote:
> On Sun, Nov 18, 2012 at 11:34 PM, David Bruant <bruant.d@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
Received on Sunday, 18 November 2012 23:54:08 GMT

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