[whatwg] URL: URLQuery

Glenn Maynard glenn at zewt.org
Fri Oct 12 15:02:46 PDT 2012


On Fri, Oct 12, 2012 at 11:10 AM, Anne van Kesteren <annevk at annevk.nl>wrote:

> I didn't really get around to working on URLs this week like I
> planned, but I managed to draft the query API that was discussed in
> the last thread:
>
> http://url.spec.whatwg.org/#urlutils
>
> get() returns the first value. getAll() returns all values. set()
> either sets a single or multiple values. delete() well, deletes.
>

The object paradigm is more natural for the common case:

query.values["key"] = value; // get()
console.log(query.values["key"]); // set()
delete query.values["key"]; // delete()
query.getAll("key"); // stays as-is

Based on discussion in #whatwg
> http://krijnhoetmer.nl/irc-logs/whatwg/20121012#l-981 I did not go
> with a design that would require proxies when implemented in
> JavaScript.
>

The questions there (query parameter called "length", "interface and the
data separate", "number of parameters") may have made sense for the
original link that was posted, but the text in that page has changed and I
never saw it.  None of those questions seem to apply to the above interface.

We're throwing away a ton if we suddenly decide not to take advantage of
JavaScript's native syntax for dictionary-like object access.

-- 
Glenn Maynard



More information about the whatwg mailing list