Re: [DOM4] Mutation algorithm imposed order on document children

On Tue, Jun 12, 2012 at 10:48 AM, Elliott Sprehn <esprehn@gmail.com> wrote:

>
>
> On Mon, Jun 11, 2012 at 9:17 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>
>>  On 6/11/12 7:39 PM, Elliott Sprehn wrote:
>>
>>> After discussing this with some other contributors there were questions
>>> on why we're enforcing the order of the document child nodes.
>>>
>>
>> Because otherwise serialization of the result would be ... very broken?
>
>
> Inserting doctype nodes has no effect on the mode of the document though,
> so it's already possible to produce a broken serialization (one in the
> wrong mode). For instance you can remove the doctype node and then
> serialize or swap the doctype node and then serialize.
>
>
>>
>>  Can we leave the behavior when your document is out of order unspecified?
>>>
>>
>> You mean allow UAs to throw or not as they wish?  That seems like a
>> pretty bad idea, honestly.  We should require that the insertion be allowed
>> (and then specify what DOM it produces) or require that it throw.
>
>
We should specify it to be allowed IMO unless there is actually a valid
use-case.


>  In practice I don't think anyone inserts these in the wrong order (or
> insert doctypes at all since they have no effect). If you wanted to
> dynamically create a document you'd do it with document.write('<!DOCTYPE
> html>') and then replaceChild the root element which was created for you.
>

I think you can make a stronger argument. It's extremely rare to create a
doctype and append it to a document at all since it doesn't affect the
compat mode. What's the use-case?

Boris, does appending a doctype to a document change compatMode in gecko in
some cases? I don't know of any effect it has in WebKit.


>  Implementing this ordering restriction requires changing the append and
> replace methods substantially in Webkit for a case I'm not sure developers
> realize exists.
>
> - Elliott
>

Received on Tuesday, 12 June 2012 18:04:19 UTC