Re: How can I create a HTMLDocument from the DOMImplementation

On Sat, Aug 29, 2009 at 10:53 PM, Ian Hickson<ian@hixie.ch> wrote:
> On Wed, 19 Aug 2009, Jonas Sicking wrote:
>> >> >
>> >> > Yeah, that's one way. Immediately call .open() on the Document
>> >> > after creating it.
>> >>
>> >> Wow, that's a really unintuitive design. Why was this design chosen?
>> >
>> > It wasn't really chosen. I think we just ended up there while trying
>> > to address other issues.
>>
>> What other issues?
>
> document.write and XML, getting EOF to work in the tokeniser, handling of
> timouts and pending database accesses across document.open() and across
> history traversal, etc.
>
>
>> I.e. what would be lost by making the choise between a "text/html
>> document" vs "non-text/html document" be chosen at construction time?
>>
>> One thing that seems unfortunate with the current API is that you can
>> call .open() on a document dynamically, thus changing behavior of any
>> node which has that node as ownerDocument (note that while nodes are
>> removed from the document when .open() is called, they don't change
>> ownerDocument).
>
> There are lots of unfortunate things with the current model, but I'm not
> sure they're a big deal.
>
> What would you like document.open() to do if called on an XML document if
> we don't convert to an HTML document?

Make document.open() do nothing other than throw an exception. That's
what we do now:

http://mxr.mozilla.org/mozilla-central/source/content/html/document/src/nsHTMLDocument.cpp#1796

/ Jonas

Received on Sunday, 30 August 2009 02:56:40 UTC