[kupu-checkins] r55355 - kupu/branch/kupu-1.4-silva/common

eric at codespeak.net eric at codespeak.net
Wed May 28 17:03:43 CEST 2008


Author: eric
Date: Wed May 28 17:03:42 2008
New Revision: 55355

Modified:
   kupu/branch/kupu-1.4-silva/common/kupuhelpers.js
Log:
fix by jasper for firefox 3 problems



Modified: kupu/branch/kupu-1.4-silva/common/kupuhelpers.js
==============================================================================
--- kupu/branch/kupu-1.4-silva/common/kupuhelpers.js	(original)
+++ kupu/branch/kupu-1.4-silva/common/kupuhelpers.js	Wed May 28 17:03:42 2008
@@ -774,7 +774,7 @@
             while (child) {
                 // XXX the additional conditions catch some invisible
                 // intersections, but still not all of them
-                if (range.intersectsNode(child) &&
+                if (rangeIntersectsNode(range, child) &&
                     !(child == startNode && startOffset == child.length) &&
                     !(child == endNode && endOffset == 0)) {
                     if (selectedChild) {
@@ -1409,3 +1409,21 @@
     image.height = height;
     image.width = width;
 };
+
+// Following function is to replace the deprecated range.intersectsNode
+// see http://developer.mozilla.org/en/docs/DOM:range.intersectsNode
+// for more info
+
+function rangeIntersectsNode(range, node) {
+  var nodeRange = node.ownerDocument.createRange();
+  try {
+    nodeRange.selectNode(node);
+  }
+  catch (e) {
+    nodeRange.selectNodeContents(node);
+  }
+
+  return range.compareBoundaryPoints(Range.END_TO_START, nodeRange) == -1 &&
+         range.compareBoundaryPoints(Range.START_TO_END, nodeRange) == 1;
+}
+


More information about the kupu-checkins mailing list