Ticket #283 (closed defect: fixed)

Opened 11 months ago

Last modified 5 months ago

isChildNode needs extra check for onMouseEnter

Reported by: kkaiser@revolution-records.net Assigned to: cederberg@gmail.com
Priority: normal Milestone: MochiKit 1.4
Component: component1 Version:
Severity: normal Keywords:
Cc:

Description

The synthetic event "onmouseenter" calls MochiKit.DOM.isChildNode and one (complicated) test-case that I've put together for a client that attaches a handful of onmouseenter events to elements in the DOM will occasionally throw an error that passes null as the first parameter of isChildNode() when you're using drag-and-drop in conjunction with onmouseenter and wildly drag the mouse around the screen.

The solution is to just check for node and node.tagName in the while loop of isChildNode; I've included a patch below.

Change History

11/27/07 07:36:29 changed by therve@gmail.com

Where's the patch?

Anyway, this is probably already the case in trunk. Can you check it?

03/16/08 23:01:00 changed by cederberg@gmail.com

There is indeed at least one error in MochiKit.DOM.isChildNode. It fails with any DOM node that isn't an element, such as text DOM nodes. Here is a test case for test_MochiKit-DOM.html:

ok( isChildNode($('child').firstChild, 'parentTwo'), "isChildNode text node");

I think the fix for this issue is to skip the whole tagname checking:

--- MochiKit/DOM.js     (revision 1327)
+++ MochiKit/DOM.js     (working copy)
@@ -355,20 +355,15 @@
         if (typeof(maybeparent) == "string") {
             maybeparent = self.getElement(maybeparent);
         }
-        if (typeof(node) == 'undefined' || node === null || node === self._document) {
+        if (typeof(node) == 'undefined' || node === null) {
             return false;
         }
-        do {
+        while (node !== self._document) {
             if (node === maybeparent) {
                 return true;
             }
-            var tagName = node.tagName;
             node = node.parentNode;
-            if (!tagName) {
-                break;
-            }
-            tagName = tagName.toUpperCase();
-        } while (tagName != "BODY" && tagName != "HTML");
+        }
         return false;
     },

Perhaps Bob knows why we are checking for HTML and BODY tags? Something to do with frames or IFRAME:s?

03/17/08 00:00:51 changed by cederberg@gmail.com

  • owner changed from somebody to cederberg@gmail.com.
  • status changed from new to assigned.

I just committed the changes to isChildNode(). Could you please check if this problem persists?

05/13/08 12:40:45 changed by cederberg@gmail.com

  • status changed from assigned to closed.
  • resolution set to fixed.

Closing this issue due to lack of feedback. Issue probably resolved with latest changes to isChildNode().