div.innerHTML = "<p>&nbsp;x</p>"

RESOLVED DUPLICATE of bug 445166

Status

()

Firefox
General
--
major
RESOLVED DUPLICATE of bug 445166
10 years ago
10 years ago

People

(Reporter: Dirk, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0

JavaScipt:

if you want to set the innerHTML of a dom element and the string contains '&nbsp;' an error will occur.
Do you know a nice way to fix this?

Reproducible: Always

Steps to Reproduce:
write the javascript:

var div = document.createElement("div");
div.innerHTML = "<p>&nbsp;x</p>";
Actual Results:  
(using firebug)
uncaught exception: [Exception... "Component returned failure code: 0x80004003 
(NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://localhost/petreltrunk/jscript/common.js :: setInnerHTML :: line 1062" data: no]
[Break on this error] undefined

Comment 1

10 years ago
Created attachment 328927 [details]
Testcase

WFM: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0

Comment 2

10 years ago
Dirk, do you get the error when you load the attachment in comment 1?
(Reporter)

Comment 3

10 years ago
yes, that code runs... but it doesn't in the asp project I'm working on. So now I see the error is a combination of FF and the asp code. I'm trying to debug it, so you can wait for a while.

Comment 4

10 years ago
Ok, please file a new bug report when you figure it out so that the bug is easy to follow.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → INVALID
(Reporter)

Comment 5

10 years ago
the content-type was set to application/xhtml+xml

maybe you can add a warning when this happens

Comment 6

10 years ago
> the content-type was set to application/xhtml+xml

That was it, thanks for figuring it out!  I do think it's a bug.  I filed a clean bug report, bug 445166.
Resolution: INVALID → DUPLICATE
Duplicate of bug: 445166
You need to log in before you can comment on or make changes to this bug.