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

Re: [whatwg] URL: URLQuery

From: Glenn Maynard <glenn@zewt.org>
Date: Fri, 12 Oct 2012 17:02:46 -0500
Message-ID: <CABirCh81H3rRiAX7k2rsYTxCMSZ3m_SSaXRKm9nn8iqN9CFYZQ@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: WHATWG <whatwg@whatwg.org>
On Fri, Oct 12, 2012 at 11:10 AM, Anne van Kesteren <annevk@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
Received on Friday, 12 October 2012 22:03:16 GMT

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