[whatwg] New URL Standard
Tab Atkins Jr.
jackalmage at gmail.com
Mon Sep 24 10:30:06 PDT 2012
On Mon, Sep 24, 2012 at 2:34 AM, Anne van Kesteren <annevk at annevk.nl> wrote:
> I have been thinking about introducing a .query attribute that would
> return a special interface for this purpose, but what the right API
> should be seems somewhat tricky. Adam and Erik came up with a solution
> that introduces eight new methods (see
> http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#url ) but I hope
> we can find something more elegant. (Unless we are stuck with their
> solution for some reason, but I believe that is not the case.)
Yeah, that interface is pretty unfriendly.
I suggest just making it a map from String->[String]. You probably
want a little bit of magic - if the setter receives an array, replace
the current value with it; anything else, stringify then wrap in an
array and replace the current value. The getter should return an
empty array for non-existing params. You should be able to set .query
itself with an object, which empties out the map and then runs the
setter over all the items. Bam, every single methods is now obsolete.
~TJ
More information about the whatwg
mailing list