[KSS-checkins] r50419 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . kukit

reebalazs at codespeak.net reebalazs at codespeak.net
Mon Jan 7 10:59:10 CET 2008


Author: reebalazs
Date: Mon Jan  7 10:59:08 2008
New Revision: 50419

Modified:
   kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/   (props changed)
   kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/forms.js
Log:
Fix getValueOfFormElement on Safari 3.0.3

this fixes formVar() on radio buttons, in this browser
reason why this is needed, is probably some change in the dom api).

Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/forms.js
==============================================================================
--- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/forms.js	(original)
+++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/forms.js	Mon Jan  7 10:59:08 2008
@@ -195,13 +195,21 @@
                 }
             }
         }
+    // Safari 3.0.3 no longer has "item", instead it works
+    // with direct array access []. Although other browsers
+    // seem to support this as well, we provide checking
+    // in both ways. (No idea if item is still needed.)
     } else if (typeof element.length != 'undefined' && 
-        typeof element.item != 'undefined' && 
-        element.item(0).type == "radio") {
+        ((typeof element[0] != 'undefined' && 
+        element[0].type == "radio") ||
+        (typeof element.item(0) != 'undefined' &&
+        element.item(0).type == "radio"))) {
+        // element really contains a list of input nodes,
+        // in this case.
         var radioList = element;
         value = null;
         for (var i=0; i < radioList.length; i++) {
-            var radio = radioList.item(i);
+            var radio = radioList[i] || radioList.item(i);
             if (radio.checked) {
                 value = radio.value;
             }
@@ -230,6 +238,8 @@
     // Extract the value of a formvar
     var value = null;
     var element = form[name];
+    // (in case of a radio button this will give a collection
+    // that contains the list of input nodes.)
     if (element) {
         var value = fo.getValueOfFormElement(element);
 ;;;     if (value != null) {


More information about the Kukit-checkins mailing list