[whatwg] URL decomposition on HTMLAnchorElement interface

Ian Hickson ian at hixie.ch
Tue Apr 28 17:28:58 PDT 2009


On Thu, 26 Mar 2009, Kartikaya Gupta wrote:
>
> It seems that major browsers all support URL decomposition on 
> HTMLAnchorElement, but this doesn't seem to be stated anywhere in the 
> HTML5 spec. The jQuery/tabs library seems to depend on this 
> (specifically, on the "hash" property) being available. Could the 
> HTMLAnchorElement interface be updated to reflect this?

Done.


On Thu, 26 Mar 2009, João Eiras wrote:
>
> Browsers also support partially setting each of the url fields 
> separately, although error handling between all of them is very 
> inconsistent. Note: if you specify this behavior, then you need to 
> specify what happens for http:, https:, data:, mailto: and unknown:

Done.

Browsers differ in how this is handled; the spec doesn't quite match any 
of them (it takes the most sane aspects of each browser I tested).


On Thu, 26 Mar 2009, Boris Zbarsky 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 
> can't speak to what happens in other browsers.

Done.


On Thu, 26 Mar 2009, Kartikaya Gupta wrote:
> 
> 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"

The spec says "null" and "http://null:123/foo?bar#baz".

If WebIDL changes to say that 'null' becomes "", then the spec says 
"example.org" and "http://example.org:123/foo?bar#baz" (setting 'host' or 
'hostname' to the empty string is ignored).


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

If 'null' becomes "null": "null", "/path", and "scheme://null/path".

If 'null' becomes "": "host", "/path", and "scheme://host/path" (setting 
'host' or 'hostname' to the empty string is ignored).


On Thu, 26 Mar 2009, Biju wrote:
> 
> var a = document.createElement('a');

Assuming a base URL of "http://example.com/path/":

> a.setAttribute('href', 'http:/Example.org:123/foo?bar#baz');   //Case 1
> alert(a.href);

Per spec: "http://example.com/Example.org:123/foo?bar#baz"


> a.setAttribute('href', 'http:example.org:123/foo?bar#baz');    //Case 2
> alert(a.href);

Per spec: "http://example.com/path/Example.org:123/foo?bar#baz"


> a.setAttribute('href', 'http:///example.org:123/foo?bar#baz');    //Case 3
> alert(a.href);

Per spec: "" (the URL can't be parsed).


> a.setAttribute('href', 'http://///example.org:123/foo?bar#baz');    //Case 4
> alert(a.href);

Per spec: "" (the URL can't be parsed).

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list