innerHTML setter does accept all entities (e.g. MathML's ∫)

RESOLVED INVALID

Status

()

Core
XML
RESOLVED INVALID
12 years ago
10 years ago

People

(Reporter: Peter Staab, Unassigned)

Tracking

({testcase})

Trunk
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(2 attachments)

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5

Firefox (Gecko specifically) reports an undefined entity error when using MathML entities in a dynamic way (via javascript and the innerHTML property).  If the same code is written statically, there is no error.  See http://www.wallabyrex.net/math/test-innerHTML-mathml.xml as a test page I wrote to demonstrate this.  

The specific error is:

Error: unknown XML entity Integral
Source File: http://www.wallabyrex.net/math/test-innerHTML-mathml.xml
Line: 31, Column: 86
Source Code:
<parent xmlns=''><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mo>&Integral;</mo>

Reproducible: Always

Steps to Reproduce:
1. Go to http://www.wallabyrex.net/math/test-innerHTML-mathml.xml
2. The javascript control will list the error


Actual Results:  
In the javascript console:

Error: unknown XML entity Integral
Source File: http://www.wallabyrex.net/math/test-innerHTML-mathml.xml
Line: 31, Column: 86
Source Code:
<parent xmlns=''><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mo>&Integral;</mo>

Expected Results:  
The same rendering both statically and dynamically.
You can't use document.write in an xml document.
The reason why you're getting the error is probably because Mozilla treats it as an E4X statement.
So I think this is invalid.

Comment 2

12 years ago
http://ln.hixie.ch/?start=1091626816&count=1
(Reporter)

Comment 3

12 years ago
I apologize for using the document.write, since my whole point was to use innerHTML, which I understand is now valid for XML pages in FF.  I have rewritten http://www.wallabyrex.net/math/test-innerHTML-mathml.xml to demonstrate the error with the entity, not MathML. 

(Reporter)

Comment 4

12 years ago
(In reply to comment #3)
> I apologize for using the document.write, since my whole point was to use
> innerHTML, which I understand is now valid for XML pages in FF.  I have
> rewritten http://www.wallabyrex.net/math/test-innerHTML-mathml.xml to
> demonstrate the error with the entity, not MathML. 
> 

I believe I have a better handle on this error.  

1. When FF interprets the static part of the page, it understands the namespace of the elements and the entities therein.  Since the mathml namespace is declared, FF interprets the mathml correctly. 

2. When xml is developed dynamically using javascript, it doesn't appear to give the elements a namespace according to a short note in the following documentation:  (http://developer.mozilla.org/en/docs/DOM:element.namespaceURI  look in the text box in the Example.  It says that "For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always NULL. ")    I would assume that MathML falls into those nodes for which this is NULL.

According to #2, however, it doesn't appear that any MathML should work, but it does as long as there are no entities.  Creating MathML dynamically is a great feature, but not very useful without all of the entities.



 
Created attachment 210797 [details]
testcase

So basically something like this should work, I guess. It works for html entity references, and because I use a mathml doctype, I think this should also work for mathm entity references. But as you can see in this case, it doesn't work for mathml entity references.

Updated

12 years ago
Assignee: nobody → general
Component: General → DOM
Keywords: testcase
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → Trunk
(Reporter)

Comment 6

12 years ago
(In reply to comment #5)
> Created an attachment (id=210797) [edit]
> testcase
> 
> So basically something like this should work, I guess. It works for html entity
> references, and because I use a mathml doctype, I think this should also work
> for mathm entity references. But as you can see in this case, it doesn't work
> for mathml entity references.
> 

I would hope for simplicity that it would be this easy to create MathML or SVG on the fly using javascript.  I used to write some pages using the cumbersome document.createElement() method and attaching children in the correct order, which was painful to write and difficult to debug, whereas having native XML documents and fragments built in to E4X is much nicer.  

Comment 7

12 years ago
Created attachment 214447 [details]
Testcase using just XHTML

I do not think it is a question of MathML. Simply a question of .innerHTML not taking DTDs from the main document into consideration. Here is a testcase using just XHTML.

Updated

12 years ago
OS: Windows XP → All
Hardware: PC → All

Comment 8

12 years ago
I believe this is a parser issue? innerHTML calls nsRange, which calls the Parser.

(my personal deal in this is, that I would like to run the S5 slide system in XHTML files... this bug stops that)

Comment 9

12 years ago
I talked with Pike and sicking on IRC. This is a generic problem as I suspected, not just MathML.
Status: UNCONFIRMED → NEW
Component: DOM → XML
Ever confirmed: true

Updated

12 years ago
Assignee: general → xml
QA Contact: ian → ashshbhatt

Updated

12 years ago
Summary: An undefined entity error when using innerHTML and mathml → innerHTML does not handle entities

Comment 10

11 years ago
It's not a document.write problem, but a innterHTML problem. It affects Gecko in general. The solution is to serve documents as HTML or to use static content. I think it's a parser problem.

Updated

10 years ago
Summary: innerHTML does not handle entities → innerHTML setter does accept all entities (e.g. MathML's &Integral;)

Updated

10 years ago
Depends on: 445166

Comment 11

10 years ago
According to bug 445166 comment 3, this is INVALID per HTML5.
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.