Closed Bug 192367 Opened 22 years ago Closed 17 years ago

Implement document.write for XMLDocument

Categories

(Core :: DOM: Core & HTML, enhancement)

PowerPC
macOS
enhancement
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 68193

People

(Reporter: dhtmlkitchen, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.2.1) Gecko/20021130
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.2.1) Gecko/20021130

Mozilla XMLDocument implements the DOM Document interface. 

It seems to me that implementing document.write for xml documents of _any_ type
should not be a problem. MathML, SVG, et c. This would be non-standard and thus
making it a mozilla extension. 

document.write is convenient. I only use it when I need it, which is seldom, but
on those rare occasions, I do really *need* it.

I am quite aware that there are other bugs similar to this. bug 111514 states
that documents with application/xhtml+xml should use HTMLDocument interface.
This is different. 



Reproducible: Always

Steps to Reproduce:



Expected Results:  
Mozilla should implement a write method for XMLDocument.

Possible complications would include character encoding and charset
complications. I don't know how this would be worked out. I don't know anything
about Mozilla API or C++.
> It seems to me that implementing document.write for xml documents of _any_
> type should not be a problem.

That's because you've never had to implement document.write() with all its
associated hackery, I would assume.  I suggest you give Mozilla's implementation
a read... that would be very edifying, I suspect.

heikki?  I'm tempted to say this is wontfix, but it's your call and jst's in the
end.
Summary: Implement document.write for XMLDocument → Implement document.write for XMLDocument
>that would be very edifying

I don't doubt that. But in no way does that decimate the indispensability of
document.write. 
Um... do you plan to use document.write from externally linked scripts?  You do
know that inline script is deprecated in XHTML, right?

And I'm not saying that it may not be _useful_, I'm just saying that the costs
(performance, correctness, time investment) of trying to do it in XML far
outweigh the benefits.  Since we're not being forced into it by backwards
compat, we should _not_ do it.

Further, see
http://www.w3.org/TR/2002/WD-DOM-Level-3-LS-20020725/load-save.html#LS-DOMBuilderthe
parseWithContext() function.  If we spend time on anything like document.write,
it should be on that...
Would this be a good time to point out that the XHTML DOM has this function?

No, I didn't think so. And yes, I thought it was a stupid idea too.
More reasons not to implement the DOM HTMLDocument interface for XML documents,
imo....
This really does sound like a bad idea. Could you provide an example of where 
you find document.write to be "indispensible" in XML? In my experience, it's 
usually "convenient" for pushing wads of malformed markup into a document.
Sorry for the delay in my response.

Tons of scripts use document.write. It can be used and abused, just like all
good things.

One scenario: 
Author decides to serve content as application/xhtml+xml and uses content neg. 

Mozilla makes an XMLDocument instance for document. The DHTML of the author's
page won't work. Forwards-compatibility is broken.

It is not convenient to make a dynamic rule creation clause. This results in
code bloat. If IE ever decided to not support document.write in xml docs (they'd
first have to support real xml), then there would be even more javascript
required because IE uses proprietary methods for styleSheets (e.g. addRule vs.
inserRule).

I'd like to continue to use document.write. According to Boris, it would be a
lot of work to support and maintain this new feature. I can't disagree with
that. If it's really true, then maybe it should mark this WONTFIX. There are a
lot of other bugs already existing anyway.

Maybe Mozilla is going to use the HTML DOM for documents loaded with
application/xhtml+xml. 
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
I assume people want document.write() to be implemented so that:

   <script type="application/x-javascript" id="script">
     document.write(data);
   </script>

...is equivalent to:

   <script type="application/x-javascript" id="script">
     source = DOMImplementation.createInputSource();
     source.stringData = data;
     DOMImplementation.createDOMBuilder(DOMImplementationLS.MODE_ASYNCHRONOUS,
       null).parseWithContext(source, document.getElementById('script'),
       DOMBuilder.ACTION_INSERT_AFTER);
   </script>

If so, then I guess we could do that (the only problem I see is getting a hold
of the <script> node from within the script). If not, then I am at a loss as to
what the request is.
Even if this functionality has not been and is not going to be corrected, a user
that has a document.write call in their XSL file will have problems. As far as I
can tell, Mozilla hangs and displays nothing. Modifying the stylesheet to remove
the offending statement and then reloading does not fix the problem either- you
have to close the tab or window and reopen the file.

Since many users are not going to expect document.write to work in their XML
processing they should at least be given a meaningful error message, lest they
attribute the lack of functionality to flawed logic within Mozilla.
The XSLT problem is bug 202765.
> a meaningful error message,

Like "document.write is not a function" in the JS console, perhaps?  Which is
what we do.
Recommend WONTFIX for this bug.  document.write is a vehicle for not-well-
formed markup.
I disagree with Alex. There are specific cases where there is no elegant
workaround for document.write(). Please fix this support. It is a "big deal" (tm)
(In reply to comment #14)
> I disagree with Alex. There are specific cases where there is no elegant
> workaround for document.write(). Please fix this support. It is a "big deal" (tm)

Please provide specific cases, preferably by e-mail so as not to clutter this
bug unnecessarily.
Please cc me on such e-mails (ian@hixie.ch). We also need to work out how to
resolve the problems I listed on my blog before this can be implemented:
   http://ln.hixie.ch/?start=1091626816&count=1
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
Component: DOM: Mozilla Extensions → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.