Closed Bug 469304 Opened 16 years ago Closed 15 years ago

Attribute nodes set with setAttributeNode get mutated

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: roc, Assigned: smaug)

References

()

Details

Attachments

(3 files, 1 obsolete file)

See the Webkit testcase. We get failures like this:
FAIL testAttribNodeNamePreservesCaseGetNode() should be A,A. Was a,a.
The attribute name in the attribute node has been lowercased after we set it. That seems wrong.
Note to myself, need to verify this is actually valid.
The testcase tests something which isn't specified anywhere.
Attributes are by default lowercase in HTML (per web compatibility).
So what I'd like to do is to make testAttribNodeNamePreservesCaseGetNode2()
fail because testAttribNodeNamePreservesCaseGetNode() fails and
make attrib.name fail because node.getAttributeNode('myattrib').name fails.
That way we would handle attributes consistently within HTML elements.
(and those are both the same bug anyway and it is a real bug.)

We could perhaps do the lowercasing already when creating attribute nodes in HTML document.

I really don't want to do what webkit does here. With latest webkit it is 
possible to add attribute nodes which values aren't available using .getAttribute().
Attached file a testcase
Taking so that I can fix the testAttribNodeNamePreservesCaseGetNode2() case.
Assignee: nobody → Olli.Pettay
Actually, I'll fix this in a bit different way.
DOMAttr.nodeName and DOMAttr.name could keep their caseness, but 
getAttribute should still work correctly.
This should fix other cases than (new XMLSerializer).serializeToString(node) should be <div myAttrib="XXX"></div>. Was <DIV myattrib="XXX"/>.
(which we do correctly IMO, because in HTML attributes are in lowercase).

Patch coming.
Attached patch possible patch (obsolete) — Splinter Review
Attachment #352785 - Flags: superreview?(jonas)
Attachment #352785 - Flags: review?(jonas)
(In reply to comment #2)
> The testcase tests something which isn't specified anywhere.
> Attributes are by default lowercase in HTML (per web compatibility).
> So what I'd like to do is to make testAttribNodeNamePreservesCaseGetNode2()
> fail because testAttribNodeNamePreservesCaseGetNode() fails and
> make attrib.name fail because node.getAttributeNode('myattrib').name fails.
> That way we would handle attributes consistently within HTML elements.
> (and those are both the same bug anyway and it is a real bug.)

FYI, this test should match IE, Opera and WebKit behaviours [1]. By failing part of it, you will be the only one to have this behaviour.
When fixing this bug on WebKit, I did not find any specification too and decided to side with IE and Opera as they had a more consistent behaviour.

> I really don't want to do what webkit does here. With latest webkit it is 
> possible to add attribute nodes which values aren't available using
> .getAttribute().

Seems like a bug. Could you file a bug about that on the WebKit bugzilla?

[1] https://bugs.webkit.org/attachment.cgi?id=22610&action=view (part of the bug https://bugs.webkit.org/show_bug.cgi?id=20247)
Julien, see the comment 5 ;)
The patch makes Gecko to pass all the other case
except XMLSerializer (). That test fails on Opera too, although in a different
way than Gecko.
Gecko serializes HTML to <DIV myattrib="XXX"/>
Opera <div myAttrib="XXX"/>
WebKit <div myAttrib=\"XXX\"></div>
(In reply to comment #8)
> Julien, see the comment 5 ;)

Oh, I had missed that. The changes you are proposing are great, sorry for the noise.
Comment on attachment 352785 [details] [diff] [review]
possible patch

This isn't working atm.
Attachment #352785 - Flags: superreview?(jonas)
Attachment #352785 - Flags: review?(jonas)
Depends on: 501226
Added also xmlns, at least temporarily. Depends on what we want to do with
Bug 501226.
Attachment #352785 - Attachment is obsolete: true
Attachment #385984 - Flags: superreview?(jonas)
Attachment #385984 - Flags: review?(jonas)
Jonas, ping
Jonas, re-ping.
Attachment #385984 - Flags: superreview?(jonas)
Attachment #385984 - Flags: superreview+
Attachment #385984 - Flags: review?(jonas)
Attachment #385984 - Flags: review+
http://hg.mozilla.org/mozilla-central/rev/27f96382b94b
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Depends on: 599590
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: