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

Re: [whatwg] URL: URLQuery

From: Glenn Maynard <glenn@zewt.org>
Date: Sat, 13 Oct 2012 10:53:06 -0500
Message-ID: <CABirCh_OdEPL4VHzXbCk=6tgPcxyt4hiyV9Cy3ErKfnsqpz7GQ@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: WHATWG <whatwg@whatwg.org>
On Fri, Oct 12, 2012 at 8:01 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

>  As you might have noticed, JS started adding things like Map in part
> because the native dictionary-like access has one significant problem: it
> looks up the prototype chain.
>

You mean, people putting extra properties on things like Object.prototype
or DOMStringMap.prototype, and breaking code doing for(a in {})?  I don't
find that to be a problem: that's nuts, so I don't do it.

It probably wouldn't hurt to actually prevent this from happening in the
first place, though, which I think is what you're suggesting below.

Unless the suggestion is that Object.getPrototypeOf(query.values) === null?
>

That, or making the prototype immutable, as if Object.freeze was called on
it.

On Sat, Oct 13, 2012 at 3:24 AM, Anne van Kesteren <annevk@annevk.nl> wrote:

> Where did .values come from?


To avoid putting object-like access and member methods on the same
interface.

I just want to make sure that if we're not using the native getter/setter
syntax, we're doing it for the right reasons.  The argument for "never
exposing any APIs that require proxies to implement in JavaScript" seems
weak.  "APIs shouldn't both act like dictionaries and have other methods on
the same object" is a good idea (and not a new one), but that's a smaller
set.

Maybe it's not worth having two interfaces (URLQuery and whatever
query.values is called) to avoid that--I don't know if that adds a lot of
complexity--but that's a separate question.

(And you reversed get()/set() right?)
>

Yeah.


> It was a more limited version of this interface (the problem with
> length was more about what would happen if you would add such a
> member):
>

Don't do that--if an object acts like a dictionary, it should have no
members of its own.


> I don't know about JavaScript Map as to whether that would be reusable
> in some way. We have some special requirements from last thread:
>
> * Keys can have more than one value.
> * Keys are ordered behind the scenes.
>
> If it is reusable that would be great. I guess Web IDL then needs to
> be updated somehow to give us some hooks.
>

FWIW, map apparently doesn't yet have iteration (according to
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Map),
which I assume is wanted here.

Where would extra WebIDL hooks be needed--isn't this just a regular WebIDL
interface to line up with?

-- 
Glenn Maynard
Received on Saturday, 13 October 2012 15:53:40 GMT

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