Work around another IE bug
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Mon, 15 Aug 2011 14:23:29 -0600
changeset 529 4ca3838a9443
parent 528 452ce350db43
child 530 6916d30e8704
Work around another IE bug
implementation.js
--- a/implementation.js	Mon Aug 15 13:53:54 2011 -0600
+++ b/implementation.js	Mon Aug 15 14:23:29 2011 -0600
@@ -3328,10 +3328,14 @@
 		&& getActiveRange().endOffset != 0
 		&& getActiveRange().endOffset != getNodeLength(getActiveRange().endContainer)) {
 			// IE seems to mutate the range incorrectly here, so we need
-			// correction here as well.
+			// correction here as well.  Have to be careful to set the range to
+			// something not including the text node so that getActiveRange()
+			// doesn't throw an exception due to a temporarily detached
+			// endpoint.
 			var newStart = [getActiveRange().startContainer, getActiveRange().startOffset];
 			var newEnd = [getActiveRange().endContainer, getActiveRange().endOffset];
-			getActiveRange().endContainer.splitText(getActiveRange().endOffset);
+			getActiveRange().setEnd(document.documentElement, 0);
+			newEnd[0].splitText(newEnd[1]);
 			getActiveRange().setStart(newStart[0], newStart[1]);
 			getActiveRange().setEnd(newEnd[0], newEnd[1]);
 		}