The following comment has been added to this issue:
Author: Lucian Holland
Created: Thu, 27 May 2004 12:30 AM
Body:
The code for node inserted/removed events is flawed in a number of ways, of which this
is just one - see also issue 941 for other problems. Obviously it would be good if a
fix sorted the whole lot out at once...
---------------------------------------------------------------------
View this comment:
http://issues.apache.org/jira/browse/XERCESJ-807?page=comments#action_35742
---------------------------------------------------------------------
View the issue:
http://issues.apache.org/jira/browse/XERCESJ-807
Here is an overview of the issue:
---------------------------------------------------------------------
Key: XERCESJ-807
Summary: dispatchEventToSubtree also dispatches to Siblings of initial Node
Type: Bug
Status: Open
Project: Xerces2-J
Components:
DOM
Versions:
2.5.0
Assignee: Xerces-J Developers Mailing List
Reporter: Christian FRANCK
Created: Mon, 13 Oct 2003 8:49 PM
Updated: Thu, 27 May 2004 12:30 AM
Environment: Operating System: Other
Platform: Other
Description:
The dispatching of events with the recursive function dispatchEventToSubtree(..)
in DocumentImpl does also dispatch to the following Siblings of the initial Node
(though they are not in the subtree).
I have quickly fixed it by splitting the function into 2 and adding a boolean to
prevent dispatching to siblings at the first level of recursion.
(Invitation to everybody to fix this properly:)
Please verify if this is correct.
Thanks,
Regards,
Christian
The following 2 functions replace the original function:
-------------------------------------------
protected void dispatchEventToSubtree(NodeImpl node, Node n, Event e) {
dispatchEventToSubtree( node, n, e,true);
}
protected void dispatchEventToSubtree(NodeImpl node, Node n, Event e,boolean
p_FirstPass) {
Vector nodeListeners = getEventListeners(node);
if (nodeListeners == null || n == null)
return;
// ***** Recursive implementation. This is excessively expensive,
// and should be replaced in conjunction with optimization
// mentioned above.
((NodeImpl) n).dispatchEvent(e);
if (n.getNodeType() == Node.ELEMENT_NODE) {
NamedNodeMap a = n.getAttributes();
for (int i = a.getLength() - 1; i >= 0; --i)
dispatchEventToSubtree(node, a.item(i), e,false);
}
dispatchEventToSubtree(node, n.getFirstChild(), e,false);
if (!p_FirstPass)dispatchEventToSubtree(node, n.getNextSibling(), e,false);
}
-------------------------------------------
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]