[KSS-checkins] r49444 - in kukit/kukit.js/branch/1.2: doc kukit

reebalazs at codespeak.net reebalazs at codespeak.net
Thu Dec 6 12:11:00 CET 2007


Author: reebalazs
Date: Thu Dec  6 12:10:55 2007
New Revision: 49444

Modified:
   kukit/kukit.js/branch/1.2/doc/HISTORY.txt
   kukit/kukit.js/branch/1.2/kukit/forms.js
Log:
 Backport critical bugfix -r49440:49442 from trunk:
Fix multiple selection form fields marshalling on Safari and IE

Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt
==============================================================================
--- kukit/kukit.js/branch/1.2/doc/HISTORY.txt	(original)
+++ kukit/kukit.js/branch/1.2/doc/HISTORY.txt	Thu Dec  6 12:10:55 2007
@@ -6,6 +6,12 @@
 
     - ...
 
+    - Fix multiple selection form fields
+      marshalling on Safari 
+      (fixes #22 in kssproject)
+      and on IE.
+      [ree]
+
     - Fix error fallback handling
       [ree]
 

Modified: kukit/kukit.js/branch/1.2/kukit/forms.js
==============================================================================
--- kukit/kukit.js/branch/1.2/kukit/forms.js	(original)
+++ kukit/kukit.js/branch/1.2/kukit/forms.js	Thu Dec  6 12:10:55 2007
@@ -60,8 +60,11 @@
         var elem = new kukit.fo.FormQueryElem(name, value);
         this.l.push(elem);
     }
+    // value.length is for detection of an Array.
+    // In addition we also check that value.pop is a function
     else if (typeof(value) == 'object' && 
-        value.constructor.toString().indexOf('Array') != -1) {
+        typeof(value.length) == 'number' &&
+        typeof(value.pop) == 'function') {
         // Special marshalling of arrays
         for (var i=0; i < value.length; i++) {
             var elem = new kukit.fo.FormQueryElem(name, value[i]);
@@ -174,10 +177,9 @@
                     value="";
                 } else {
                     var option = element.options[element.selectedIndex];
-                    value = option.value;
-                    if (value == "") {
-                        value = option.text;
-                    }
+                    // on FF and safari, option.value has the value
+                    // on IE, option.text needs to be used
+                    value = option.value || option.text;
                 } 
         // Now process selects with the multiple option set
         } else {
@@ -185,7 +187,9 @@
             for(i=0; i<element.options.length; i++) {
                 var option = element.options[i];
                 if(option.selected) {
-                    value.push(option.value);
+                    // on FF and safari, option.value has the value
+                    // on IE, option.text needs to be used
+                    value.push(option.value || option.text);
                 }
             }
         }


More information about the Kukit-checkins mailing list