InnerHtml property on xml node is completely broken

RESOLVED INVALID

Status

()

--
major
RESOLVED INVALID
12 years ago
12 years ago

People

(Reporter: d.tuppeny, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(4 attachments)

(Reporter)

Description

12 years ago
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
(Reporter)

Comment 1

12 years ago
Created attachment 246798 [details]
Test page showing the flaw

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.
(Reporter)

Updated

12 years ago
Summary: InnerHtml on xml property is completely broken → InnerHtml property on xml node is completely broken

Comment 2

12 years ago
Created attachment 246840 [details]
XHTML testcase - This testcase shows it works when using XHTML.  

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.

Comment 3

12 years ago
Created attachment 246841 [details]
HTML testcase

Updated

12 years ago
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → INVALID
(Reporter)

Comment 4

12 years ago
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 → ---
(Reporter)

Comment 5

12 years ago
Created attachment 246897 [details]
Page showing the bug using a <br /> tag as suggested in Appendix C of XHTML spec

Page showing the bug using a <br /> tag as suggested in Appendix C of XHTML spec
(Reporter)

Comment 6

12 years ago
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>
(Reporter)

Comment 7

12 years ago
(In reply to comment #6)
> This is most certainly a bug.<snip>

Whoops, typo.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.