Re: baseURI / xml:base

On 8/9/13 9:51 AM, Anne van Kesteren wrote:
> Interesting. It doesn't in other browsers:
>
> http://software.hixie.ch/utilities/js/live-dom-viewer/
> <!DOCTYPE html><base href=test>.<script>
> w(document.body.firstChild.baseURI);
> w(document.body.firstChild.cloneNode().baseURI)
> </script>

I think this is just WebKit being buggy.  Consider the slightly more 
extended testcase at 
http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2439 which 
looks like this:

<!DOCTYPE html><base href=test>.<script>
var y = document.body.firstChild;
w(y.baseURI);
y.remove();
w(y.baseURI);
var x = document.body.firstChild.cloneNode();
w(x.baseURI)
document.body.appendChild(x);
w(x.baseURI)
</script>

Here WebKit reports the document base URI, then the empty string, then 
null, then the document base URI.  That second "empty string" bit in 
particular shows that this is just a bug in WebKit's baseURI getter, not 
anything to do with cloneNode.

Per spec, for whatever that's worth and if we ignore the xml:base bits 
we have:

   Given an element, the element's base URL is the base URI of the
   element, as defined by the XML Base specification, with the base
   URI of the document entity being defined as the document base URL
   of the Document that owns the element. [XMLBASE]

which is pretty clearly using the base URI of the ownerDocument, and is 
in no way dependent on whether the element is in the DOM (in fact, the 
only dependency on position in the DOM comes from xml:base).

-Boris

Received on Friday, 9 August 2013 14:03:34 UTC