Closed Bug 362106 Opened 18 years ago Closed 18 years ago

InnerHtml property on xml node is completely broken

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: d.tuppeny, Unassigned)

Details

Attachments

(4 files)

User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1) Gecko/20061010 Firefox/2.0 When accessing the .innetHTML property of my <xml> tag, the returned value contains half of the page, and doesn't stop where it should. Reproducible: Always Steps to Reproduce: Paste the below into a document and fire the initChart() method. The returned content is not as expected. <xml id="chartData"> <data name1="Some Testt" name2="Bug Test"> <item name="Points" val1="62" val2="72.5" /> <item name="Points" val1="71" val2="132" /> <item name="Points" val1="50" val2="80" /> <item name="Points" val1="30" val2="77" /> <item name="Level" val1="3" val2="1" /> </data> </xml> <script type="text/javascript"> function initChart() { alert(document.getElementById('chartData').innerHTML); } </script> Actual Results: The returned value ignores the fact that tags are <short /> and as a result, eats up half of the page. Expected Results: The returned value should stop inside the </xml> tag. I've only tested this on: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1) Gecko/20061010 Firefox/2.0
Here's a sample showing the bug. Doctypes etc. don't seem to change it, so I left them out to keep the file simple.
Summary: InnerHtml on xml property is completely broken → InnerHtml property on xml node is completely broken
Doctypes are not what determine which parser is used. The content-type sent by the server over HTTP determines which parser is used. If you want to use XML with HTML you really should use XHTML with the application/xhtml+xml content type. There are plenty of invalid bugs in this bug database with people trying to use the short tag notation with HTML. An example is Bug 268477. It does work in HTML if you avoid the short tag notation. I'll attach that too.
Attached file HTML testcase
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → INVALID
Appendix C of the XHTML spec suggests that for XHTML to be rendered correctly when parsed as HTML: "C.2. Empty Elements Include a space before the trailing / and > of empty elements, e.g. <br />, <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br></br> allowed by XML gives uncertain results in many existing user agents." Which suggests that I *should* use <br /> when serving XHTML as HTML. This still breaks Firefox when my code looks like: <html> <body onload="initChart()"> <div id="chartData"> <font size="4"> text<br />text </font> </xml> <script type="text/javascript"> function initChart() { alert(document.getElementById('chartData').innerHTML); } </script> </body> </html>
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Page showing the bug using a <br /> tag as suggested in Appendix C of XHTML spec
This is most certainly a bug. It happens with normal HTML <br> tags without the slash too. The HTML inside my div is completely valid playing by HTML rules, yet innerHTML is still screwed up. <html> <body onload="initChart()"> <div id="chartData"> <font size="4"> text<br>text </font> </xml> <script type="text/javascript"> function initChart() { alert(document.getElementById('chartData').innerHTML); } </script> </body> </html>
(In reply to comment #6) > This is most certainly a bug.<snip> Whoops, typo.
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago18 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: