[whatwg] URL decomposition on HTMLAnchorElement interface

Kartikaya Gupta lists.whatwg at stakface.com
Fri Mar 27 18:07:21 PDT 2009

On Fri, 27 Mar 2009 17:40:08 -0400, Boris Zbarsky <bzbarsky at MIT.EDU> wrote:
> Kartikaya Gupta wrote:
> > - Attempts to set "pathname" to null should throw, since the path is a required 
> > component of a URI. Setting "pathname" to anything else should be allowed and 
> > should update the path component of the underlying URI (invalid characters are 
> > escaped).
> These are all more or less unacceptable.  Foe example, setting 
> "pathname" to empty string should work just fine, imo; setting that on 
> "http://foo.com/bar/" should result in "http://foo.com/".

The empty string falls under the "anything else" case in my suggestion above and would work as you expect.

> There are big scary comments in the Gecko code for these setters saying 
> that they must never ever throw.  I suspect that making them throw would 
> be a serious web compat issue.

Is this Gecko-internal code you're referring to? Or the setters exposed to web content via HTMLAnchorElement? And do you have any examples of websites that would break if they threw?

> Changing from an authority to a non-authority URI or the other way 
> around doesn't seem desirable to me (and would only work for unknown 
> schemes anyway, presumably, at best; it's better if it just never works).

Does it matter? Since it's an unknown scheme, it's basically opaque data. You can't dereference it and fetch the resource it points to, so is there an actual benefit from restricting the behavior?

> > - In general I made every invalid action throw rather than ignoring the attempt 
> > because I personally don't like it when things fail silently.
> That's nice, but I suspect web sites rely on the silent fail behavior here.

Examples? That being said, I'd be fine with changing them all to do the silent ignore thing instead of throwing if it turns out that throwing would break a lot of stuff.


More information about the whatwg mailing list