[whatwg] URL: URLQuery

Boris Zbarsky bzbarsky at MIT.EDU
Sat Oct 13 09:03:10 PDT 2012


On 10/13/12 11:53 AM, Glenn Maynard wrote:
> 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.

Yes, but lots of libraries do.  But even that's not the real problem.

> Unless the suggestion is that Object.getPrototypeOf(query.values) === null?
>>
>
> That, or making the prototype immutable, as if Object.freeze was called on
> it.

Making the proto immutable is not good enough.

Consider code that wants to extract a "toString" URL parameter.  How do 
you propose it go about doing that in a setup where query.values is a 
normal object with a proto chain that chains up to Object.prototype?

Note that there are lots of other property names that have the same problem.

It's not clear to me to what extent implementing as a proxy can mitigate 
this.  I suppose you could write has() and get() traps that ignore the 
proto chain, even if you for some reason want that proto chain to be 
there....

-Boris



More information about the whatwg mailing list