Closed Bug 325581 Opened 18 years ago Closed 16 years ago

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

Categories

(Core :: XML, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: peter.staab, Unassigned)

References

()

Details

(Keywords: testcase)

Attachments

(2 files)

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.
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. 

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



 
Attached file 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.
Assignee: nobody → general
Component: General → DOM
Keywords: testcase
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → Trunk
(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.  

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.
OS: Windows XP → All
Hardware: PC → All
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)
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
Assignee: general → xml
QA Contact: ian → ashshbhatt
Summary: An undefined entity error when using innerHTML and mathml → innerHTML does not handle entities
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.
Summary: innerHTML does not handle entities → innerHTML setter does accept all entities (e.g. MathML's &Integral;)
Depends on: 445166
According to bug 445166 comment 3, this is INVALID per HTML5.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: