The following issue has been updated:

    Updater: Jonathan Au (mailto:[EMAIL PROTECTED])
       Date: Wed, 26 May 2004 1:37 PM
    Comment:
XercesJ807Patch results in the desired traversal by not continuing to the nextSibling 
of the root of the original subtree.
    Changes:
             Attachment changed to XercesJ807Patch
    ---------------------------------------------------------------------
For a full history of the issue, see:

  http://issues.apache.org/jira/browse/XERCESJ-807?page=history

---------------------------------------------------------------------
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: Wed, 26 May 2004 1:37 PM
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]

Reply via email to