[whatwg] URL decomposition on HTMLAnchorElement interface

Boris wrote:
> If you specify the setters then you also need to specify how this 
> affects the value of the "href" attribute in the DOM.  For example, in 
> Gecko if you have an <a href="foo#bar"> which has base URI 
> "http://example.com/" and you set anchor.hash on that anchor to "baz", 
> then the attribute value is changed to "http://example.com/foo#baz".

I was trying different things to see what happens and came across some particularly weird behavior in Gecko/2009021910 Firefox/3.0.7:

var a = document.createElement('a');
a.setAttribute('href', 'http://example.org:123/foo?bar#baz');
a.hostname = null;
alert(a.hostname);       // displays "foo"
alert(a.href);           // displays "http://foo/?bar#baz"

a.setAttribute('href', 'scheme://host/path');
a.host = null;
alert(a.host);           // displays ""
alert(a.pathname);       // displays ""
alert(a.href);           // displays "scheme:////host/path"

This behavior seems rather inconsistent and possibly buggy. I tried looking in Bugzilla to see if anything turned up but my search keywords just kept hitting a lot of unrelated stuff so I didn't try too hard.

Cheers,
kats

Received on Thursday, 26 March 2009 14:26:46 UTC