Re: Do we need the restrictions on the <base> element?

Henrik Dvergsdal wrote:
> However, the current spec will *also* break with existing UAs.

Then we should fix the spec.  ;)

> Firefox/Explorer/Opera (current versions) don't accept relative URLs in 
> <base> (Safari does)

Compat with content is more important than compat with UAs.  In practice, 
content doesn't really rely on relative URLs in base, because the HTML4 spec says:

href = uri [CT]
     This attribute specifies an absolute URI that acts as the base URI for
     resolving relative URIs.

and certain UAs (IE, for example) implemented that.  Expanding the definition to 
allow relative URIs is not really a problem, except insofar as it doesn't 
degrade well to rendering in HTML4 UAs.  Bit of a judgement call here.

> All major browsers will use the *last* <base> while the spec says they 
> should ignore all but the *first*.

Yep.  That will probably need to be changed in the spec.  Sites definitely 
depend on this behavior; I don't think we could implement the spec as written in 
Gecko without breaking things.

In fact, current behavior in Gecko (needed for website compat, in our 
experience, but I'd be interested in learning what other UAs do) is that the 
last <base> inside <head> ends up setting the base URI for the document, with 
nodes in <head> using whatever base URI is current when they are parsed.  <base> 
tags inside the <body> end up affecting the base URIs of individual nodes (all 
the ones parsed after that <base>), but NOT the base URI of the document.

> So this is really a question of where to draw the line. How much of the 
> old functionality should be kept in the spec?

I think we should require conformant documents to have a single <base> at the 
beginning of the <head>.  What we require of UAs is a tougher call...

> It would be interesting to know the extent of this problem.

I would too.  Including how prevalent it is in intranets, HTML mail, etc.

> NB! This is not only relevant to my suggestion. I think we need research 
> on both to justify the *current decisions* made in the spec.

Absolutely agreed.

>> 1) <base> has to come before other things, we specify it nicely, any 
>> document
>>    where it _doesn't_ come before other things is non-conforming, and UAs
>>    handle such documents as they do right now
> 
> By "things" I assume you mean elements referring to URI's - not <title> 
> or <meta>?

Yes.

-Boris

Received on Wednesday, 6 June 2007 16:34:13 UTC