[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kupu-checkins
Subject:    [kupu-checkins] r58004 - kupu/trunk/kupu/common
From:       duncan () codespeak ! net
Date:       2008-09-09 13:21:33
Message-ID: 20080909132133.3ADC2169EEA () codespeak ! net
[Download RAW message or body]

Author: duncan
Date: Tue Sep  9 15:21:31 2008
New Revision: 58004

Modified:
   kupu/trunk/kupu/common/kupuhelpers.js
Log:
Make selection code more robust (FF3 source edit issue)

Modified: kupu/trunk/kupu/common/kupuhelpers.js
==============================================================================
--- kupu/trunk/kupu/common/kupuhelpers.js	(original)
+++ kupu/trunk/kupu/common/kupuhelpers.js	Tue Sep  9 15:21:31 2008
@@ -491,6 +491,7 @@
 
     this.collapse = function(collapseToEnd) {
         try {
+            if (!this.selection) this.reset();
             if (!collapseToEnd) {
                 this.selection.collapseToStart();
             } else {
@@ -783,6 +784,9 @@
     this.parentElement = function(allowmulti) {
         /* return the selected node (or the node containing the selection) */
         // XXX this should be on a range object
+        if (!this.selection) {
+            return null;
+        }
         if (this.selection.rangeCount == 0) {
             var parent = this.document.getDocument().body;
             while (parent.firstChild) {
@@ -1003,7 +1007,7 @@
     };
 
     this.getRange = function() {
-        if (this.selection) {
+        if (this.selection && this.selection.rangeCount > 0) {
             return this.selection.getRangeAt(0);
         }
     };
_______________________________________________
kupu-checkins mailing list
kupu-checkins@codespeak.net
http://codespeak.net/mailman/listinfo/kupu-checkins
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic