[whatwg] Document's base URI should use the document's *current* address

On Wed, 27 Apr 2011, Justin Lebar wrote:
>
> The document base URL is used when fetching resources.
> 
> Right now, if a page doesn't have a <base> element, the document base 
> URL is set to the document's address. ?(I'm going to call this the 
> "document's original address".) ?The document's original address does 
> not change when you call pushState; only the document's current address 
> does.
> 
> I think the base URI should use the document's current address, not the 
> original address.
> 
> To see why this makes sense, consider the following scenario:
> 
> * User loads page.html
> * Page calls pushState and changes its url to page2.html
> * User clicks on a link with href "#foo".
> 
> As currently specified, we'll resolve #foo relative to the document's 
> original URL; that is, clicking the link will take the user to 
> page.html#foo, not page2.html#foo. ?But the intent of a link with href 
> #foo is clearly to navigate within the current page, not to go somewhere 
> else.
> 
> Firefox 4 already implements pushState as I'm suggesting here.

The spec as written decides whether a link is a same-resource reference or 
not based on comparing the URLs to what you're calling the original 
address, not comparing it to the current address. See the navigation 
algorithm, step 7 /Fragment identifiers/.

Note that there are problems with what you describe: what if the new URL 
has a different path, and there are <img> elements whose URLs are 
relative, and after pushState() you clone one? Or what about relative 
links in the original markup? I don't think we can change the base URL on 
the fly, all kinds of problems could result.

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

Received on Tuesday, 19 July 2011 14:35:53 UTC