Closed Bug 364413 Opened 18 years ago Closed 18 years ago

Related node on DOMAttrModified listener isn't the same as attr node set by SetAttributeNodeNS

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: WeirdAl, Assigned: smaug)

Details

(Keywords: dom2, testcase)

Attachments

(4 files, 2 obsolete files)

Similar problem to bug 364092.  When I set an attribute via setAttributeNodeNS, the event listener on the owner element gets an event with a related node similar to, but not exactly, the node being set.

Testcase coming up as an attachment.

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061219 SeaMonkey/1.5a
Attached file testcase (obsolete) —
Summary: Related node on DOMAttrModifed listener isn't the same as attr node set by SetAttributeNodeNS → Related node on DOMAttrModified listener isn't the same as attr node set by SetAttributeNodeNS
Attached file relevant stack trace
In this case, nsDOMAttributeMap::SetNamedItemInternal() calls on nsGenericElement::SetAttr(), but does not pass in the original node.  Later on, we have a call to GetNamedItemNS(), which tries to find the new attribute.  No attribute has been set yet, so we create a new one.  Ergo, we fail the test.
Attached patch patch, v1 (obsolete) — Splinter Review
Thanks to smaug for inspiring this patch with his patch for the removeAttributeNode case.  It took me a couple hours to see this myself.
Attachment #249217 - Flags: superreview?(bugmail)
Attachment #249217 - Flags: review?(bugmail)
Assignee: general → ajvincent
Comment on attachment 249217 [details] [diff] [review]
patch, v1

Uh, oops.  We lost the new value of the attribute with this patch.
Attachment #249217 - Flags: superreview?(bugmail)
Attachment #249217 - Flags: review?(bugmail)
Attachment #249197 - Attachment is obsolete: true
Attached patch patch, v1.1Splinter Review
This patch gets the attribute value, and the event has the correct prevValue and newValue settings (according to Venkman).
Attachment #249217 - Attachment is obsolete: true
Attachment #249222 - Flags: superreview?(bugmail)
Attachment #249222 - Flags: review?(bugmail)
Won't event.relatedNode.ownerElement be wrong with this patch? I.e. don't you want to call SetMap before calling SetAttr and solve the value problem some other way (I'm not sure I fully understand the comment in the patch)
Comment on attachment 249222 [details] [diff] [review]
patch, v1.1

Nuts, you're right.  As Mike Rowe would call it, "rookie mistake!"

smaug, do you want to take this on and do it right?
Attachment #249222 - Flags: superreview?(bugmail)
Attachment #249222 - Flags: review?(bugmail)
(In reply to comment #8)
> (From update of attachment 249222 [details] [diff] [review] [edit])
> Nuts, you're right.  As Mike Rowe would call it, "rookie mistake!"
> 
> smaug, do you want to take this on and do it right?
> 

Ok :)
Assignee: ajvincent → Olli.Pettay
Attached patch proposed patchSplinter Review
Attachment #249252 - Flags: superreview?(bugmail)
Attachment #249252 - Flags: review?(bugmail)
Attachment #249252 - Flags: superreview?(bugmail)
Attachment #249252 - Flags: superreview+
Attachment #249252 - Flags: review?(bugmail)
Attachment #249252 - Flags: review+
I'll add the .ownerElement test to the testcase and add that to mochitest.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Flags: in-testsuite+
Component: DOM: Core → DOM: Core & HTML
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: