Closed
Bug 364092
Opened 18 years ago
Closed 18 years ago
Related node on DOMAttrModified listener isn't the same as attr node removed by RemoveAttributeNode
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: WeirdAl, Assigned: smaug)
Details
(Keywords: dom2, testcase)
Attachments
(3 files)
1.08 KB,
application/vnd.mozilla.xul+xml
|
Details | |
10.70 KB,
text/plain
|
Details | |
948 bytes,
patch
|
sicking
:
review+
sicking
:
superreview+
|
Details | Diff | Splinter Review |
When I drop an attribute via the RemoveAttributeNode() method, an event listener on the owner element (or an ancestor) gets an event with a related node that is similar to, but not exactly, the same node being removed.
Testcase coming up as an attachment.
Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.9a1) Gecko/20061216 SeaMonkey/1.5a
also seen on Windows, OS->All, Platform->All. This is not a regression; the same bug is known to exist on Firefox 2.
Reporter | ||
Comment 1•18 years ago
|
||
Steps to reproduce: Load the test page.
Reporter | ||
Comment 2•18 years ago
|
||
In nsDOMAttributeMap::GetAttribute (frame 03), we try to find the attribute. However, the lookup fails, so at nsDOMAttributeMap.cpp#160 we create a new DOM attribute object with an empty attribute value. It is this new node which gets set as the related node of the event, instead of the original node.
Reporter | ||
Comment 3•18 years ago
|
||
So nsDOMAttributeMap::RemoveNamedItem is interesting. First it calls GetAttribute(ni, aReturn, PR_TRUE). The third argument says "Remove the attribute," which GetAttribute helpfully does.
Then it calls mContent->UnsetAttr(ni->NamespaceID(), ni->NameAtom(), PR_TRUE), which leads to the code for the mutation event to get the attribute node.
What would the impact be of simply switching these two calls?
Assignee | ||
Comment 4•18 years ago
|
||
This should do it, or am I missing something ...
First create the attr node normally using GetAttribute, and
then it gets removed from the map when UnsetAttr is called.
Attachment #248985 -
Flags: superreview?(bugmail)
Attachment #248985 -
Flags: review?(bugmail)
Reporter | ||
Comment 5•18 years ago
|
||
smaug: so if I'm reading the code right, nsXULElement::UnsetAttr and nsGenericElement::UnsetAttr both call on slots->mAttributeMap->DropAttribute(aNameSpaceID, aName) to get rid of the attribute.
I notice the code for nsDOMAttributeMap::DropAttribute is very similar to code for the latter half of nsDOMAttribute::GetAttribute(), so I think that achieves our objective. Just as an aside for future work, would it be worth combining the two?
Comment on attachment 248985 [details] [diff] [review]
proposed patch
That's simple enough :)
Attachment #248985 -
Flags: superreview?(bugmail)
Attachment #248985 -
Flags: superreview+
Attachment #248985 -
Flags: review?(bugmail)
Attachment #248985 -
Flags: review+
Assignee | ||
Updated•18 years ago
|
Assignee: general → Olli.Pettay
Assignee | ||
Updated•18 years ago
|
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 7•18 years ago
|
||
I'll want to add this to a DOM test suite (there isn't one from the W3C for DOM Events).
Flags: in-testsuite?
Summary: Related node on DOMAttrModifed listener isn't the same as attr node removed by RemoveAttributeNode → Related node on DOMAttrModified listener isn't the same as attr node removed by RemoveAttributeNode
Assignee | ||
Updated•18 years ago
|
Flags: in-testsuite? → in-testsuite+
Reporter | ||
Comment 8•18 years ago
|
||
smaug, I don't see a patch or checkin that put this bug's testcase into the test harnesses; where was it added?
Assignee | ||
Comment 9•18 years ago
|
||
There is a modified mochitest testcase.
You need to log in
before you can comment on or make changes to this bug.
Description
•