W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2009

[whatwg] URL decomposition on HTMLAnchorElement interface

From: Kartikaya Gupta <lists.whatwg@stakface.com>
Date: Thu, 26 Mar 2009 21:26:46 +0000
Message-ID: <20090326212648.4C5838DB002D@zapata.dreamhost.com>
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 GMT

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