[whatwg] Expected behaviour when a <base> is within an innerHTML fragment

On 11 Feb 2007, at 15:11, Geoffrey Sneddon wrote:

> The point is whether it:
> 	a) Gets inserted into the <head>, and changes all the links in the  
> document.
> 	b) Appears in some magic place, and changes the links in the HTML  
> fragment.
> 	c) Gets ignored.
>
> I'm personally in favour of b), as using the normal parsing rules  
> (placing it in <head>) may well end up changing more than what is  
> wanted. I'll do some testing of current implementations later.

So? the testing:

For reference, I'll note the behaviour as such:
	1: Changes all links in the document.
	2: Changes links in HTML fragment.
	3: Changes nothing.

Test 1: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C% 
21DOCTYPE%20html%3E%0A%3Cscript%20type%3D%22text/javascript%22%3E% 
0Afunction%20insert_base%28%29%0A%7B%0A%09document.getElementById%28% 
22insert%22%29.innerHTML%3D%22%3Cbase%20href%3D%27http%3A// 
example.org/%27%3E%3Ca%20href%3D%27test%27%3Etest2%3C/a%3E%22%3B%0A%7D 
%0A%3C/script%3E%0A%3Cbase%20href%3D%22http%3A//example.com/%22%3E%0A% 
3Cp%3E%3Ca%20href%3D%22test%22%3ETest%3C/a%3E%3C/p%3E%0A%3Cp%20id%3D% 
22insert%22%3E%3Ca%20href%3D%22javascript%3Ainsert_base%28%29%22% 
3Einsert%3C/a%3E%3C/p%3E%0A%3Cp%3E%3Ca%20href%3D%22test%22%3ETest%3C/a 
%3E%3C/p%3E

Safari 2.0.4/419.3: (1) Inserted in DOM (in the innerHTML location).
Firefox 2.0.0.1: (3) Inserted in DOM (in the innerHTML location).
IE/Mac 5.2.3: (2) (anyway to view the DOM tree?)
Opera 9.10: (1) DOM Snapshot for some reason isn't working.
IE6/Win: (2) The new <base> never appears in DOM, but the full  
absolute URLs are in the DOM.
IE7/Win: (3) The new <base> never appears in DOM, but the full  
absolute URLs are in the DOM.

Test 2 (this uses onclick to avoid escaping it as a URI): http:// 
software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html% 
3E%0A%3Cbase%20href%3D%22http%3A//example.com/%22%3E%0A%3Cp%3E%3Ca% 
20href%3D%22test%22%3ETest%3C/a%3E%3C/p%3E%0A%3Cp%20id%3D%22insert%22% 
3E%3Ca%20onclick%3D%22document.getElementById%28%26quot%3Binsert% 
26quot%3B%29.innerHTML%3D%26quot%3B%3Cbase%20href%3D%27http%3A// 
example.org/%27%3E%3Ca%20href%3D%27test%27%3Etest2%3C/a%3E%26quot%3B% 
22%3Einsert%3C/a%3E%3C/p%3E%0A%3Cp%3E%3Ca%20href%3D%22test%22%3ETest% 
3C/a%3E%3C/p%3E

Results the same as above.

In conclusion, Safari and Opera change all the links, IE5/Mac and IE6/ 
Win both change links within the fragment, and Firefox and IE7/Win  
don't change any links.


- Geoffrey Sneddon

Received on Sunday, 11 February 2007 07:57:51 UTC