Closed
Bug 234634
Opened 21 years ago
Closed 3 years ago
innerHTML doesn't work right in some cases
Categories
(Core :: DOM: Core & HTML, defect, P5)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: neil, Unassigned)
Details
(Whiteboard: DUPEME)
Attachments
(1 file)
821 bytes,
text/html
|
Details |
Source: <textarea></textarea></textarea> textarea's innerHTML: </textarea> Source: <div><xmp>&</xmp><div> div's innerHTML: <xmp>&amp;</xmp>
Comment 1•21 years ago
|
||
<xmp> probably needs to override GetInnerHTML and call GetContentsAsText like textarea does.
Summary: innerHTML doesn't work in some cases → innerHTML doesn't work right on <xmp>
Reporter | ||
Comment 2•21 years ago
|
||
Just to clarify, it does work correctly in these cases: Source: <div><textarea></textarea></textarea></div> div's innerHTML: <textarea></textarea></textarea> Source: <xmp>&</xmp> xmp's innerHTML: &
Summary: innerHTML doesn't work right on <xmp> → innerHTML doesn't work right in some cases
Comment 3•21 years ago
|
||
Oh, I see. So the problem is that the innerHTML needs to be "whatever, when parsed in the context of this node, will give the current DOM". So the creation of innerHTML requires a lot more parser knowledge than we currently use (or want to use, imo).
Isn't the bug really in the html-serializer? That it shouldn't escape stuff inside elements that the parser won't unescape once parsed again? That way we wouldn't need to have special implementations of .innerHTML in various elements since that strategy apparently doesn't work.
Reporter | ||
Comment 5•21 years ago
|
||
What I expect is that setting aElement.innerHTML = aElement.innerHTML; should have no "visible" effect in the DOM, but with the xmp example all the <>&s become escaped, because the setter works correctly. A version of the bug affects editor as well, as when you save or switch into source mode all the <>&s in an <xmp> block become escaped. (4.x used to work around the problem by converting them all to <pre>s). I don't understand why textareas were special-cased at all. Support for unescaped <>&s in textareas is just another backward compatibility quirk.
Comment 6•21 years ago
|
||
> I don't understand why textareas were special-cased at all.
Because otherwise, real-world sites broke. Which is really just not an issue
with <xmp>.... ;)
Comment 7•21 years ago
|
||
Do we not recurse when doing getInnerHTML ?
Nope, we just ask the html-serializer to serialize the children of the node.
or rather, we ask it to serialize the contents of the node. I.e. we only make one call to the serializer.
Comment 10•21 years ago
|
||
Ah. In that case yeah, we should fix the HTML serialiser for XMP. Why does it work for <xmp> directly though? Does XMP already have a getInnerHTML jobbie? (the <textarea> case is a special case; <xmp> should be the same whether done via it directly or its parent.)
Calling .innerHTML direcly on the xml-element works because the element has an explicit implementation of GetInnerHTML. See http://lxr.mozilla.org/mozilla/source/content/html/content/src/nsHTMLSpanElement.cpp#145 What is special about textarea? Why should it behave differently when .innerHTML is called on its parent?
Comment 12•21 years ago
|
||
<textarea> is special because IE has a bug with it which sites depend on.
Reporter | ||
Comment 13•21 years ago
|
||
Hixie, I tried IE5 and IE6, with this simple HTML; both display <&> <textarea onclick="alert(innerHTML)"><&></textarea>
Comment 14•21 years ago
|
||
I was just basing my comments on what bz said earlier in this bug. bz?
Comment 15•20 years ago
|
||
Hmm.. So the textarea special-casing was done in bug 125746 (needed for setInnerHTML, sorta, though I guess what we have now screws up entity references....). It may not in fact be needed for getInnerHTML on textarea. Except then we'll break the invariant that: foo.innerHTML = foo.innerHTML; doesn't change anything (it's broken for XMP right now, and it would break for textarea if we made that change). Unless we fix those entity reference issues, of course. So the point is, we need to have a much smarter serializer. Editor probably wants that too, for roundtripping.....
Comment 16•19 years ago
|
||
I have a similar issue: form.innerHTML does not serialize the value on user inputs (i.e., the value of <input>, e.g., <input type="text">). This is a big deal for me since I am dynamically generating highly hierarchical structs. It is difficult for me to read and save all these values manually.
Comment 17•19 years ago
|
||
That's a separate issue, and Mozilla's behavior there is correct; please see the existing (invalid) bugs filed on it...
Comment 18•19 years ago
|
||
Can you show us which bug it is? I can find out. I am not sure this is the correct behavor. innerHTML is an IE extension to DOM. If Firefox decides to support it (which it does), should it use IE as reference? I tested in IE 6.0, it does serialize the form data (user input).
Comment 19•19 years ago
|
||
I can find out --> I can not find it.
Comment 20•19 years ago
|
||
> I tested in IE 6.0, it does serialize the form data (user input).
IE serializes whatever getAttribute returns, as does Mozilla. The problem is
that for form controls getAttribute in IE is buggy.
Updated•15 years ago
|
Assignee: general → nobody
QA Contact: ian → general
Comment 21•14 years ago
|
||
Test case proving innerHTML is working incorrectly in Firefox 4.0b2. (Version Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b2) Gecko/20100720 Firefox/4.0b2)
Comment 22•14 years ago
|
||
Comment on attachment 463148 [details]
Well formed XML, badly parsed in Firefox 4
Look at console.log to see the results of the parsing.
Comment 23•14 years ago
|
||
Tim, what is console.log? I get error "console is not defined" Anyway, your file is html, so innerHTML uses html parsing, not XML parsing.
Comment 24•14 years ago
|
||
Olli, Tim's assuming that everyone runs Firebug (bad assumption). You're correct that his testcase has nothing to do with this bug (which has a summary so broad as to be useless, but is in fact about the innerHTML _getter_). This bug seems to be a duplicate of the "implement html5 spec for innerHTML" bug.
Whiteboard: DUPEME
Assignee | ||
Updated•11 years ago
|
Component: DOM: Mozilla Extensions → DOM
Comment 25•6 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Assignee | ||
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
Updated•3 years ago
|
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•