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

reebalazs at codespeak.net reebalazs at codespeak.net
Fri Jan 4 17:57:39 CET 2008


Author: reebalazs
Date: Fri Jan  4 17:57:38 2008
New Revision: 50323

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/dom.js
   kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js
Log:
Fix code by testing.
Add KssIdOfValue provider.

Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js
==============================================================================
--- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js	(original)
+++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js	Fri Jan  4 17:57:38 2008
@@ -318,6 +318,9 @@
     // This means setting an attribute to '' is the same as deleting it - 
     // at least at the moment
     if (! result) {
+        // Make sure result is null, in case we can't produce one
+        // below.
+        result = null;
         // Now try to get it from the class and id encodings.
         // Having it in the id gives the advantage that we can use
         // kss-id-key-value both as a unique html id, and widget markup.
@@ -337,9 +340,8 @@
         // Get the result-
         var prefix = namespacedName + '-' + key;
         return _getKssValueFromEncodings(encodings, prefix);
-    } else {
-        return null;
     }
+    return result;
 };
 
 dom.setKssValue = function(node, keyType, key, value) {

Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js
==============================================================================
--- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js	(original)
+++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js	Fri Jan  4 17:57:38 2008
@@ -158,8 +158,7 @@
         if (args.length == 2) {
 ;;;         kukit.E = '2nd attribute of currentFormVarForKssAttr must be a';
 ;;;         kukit.E += ' boolean';
-            kukit.ut.evalBool(args[1], kukit.E);
-            recurseParents = args[1];
+            recurseParents = kukit.ut.evalBool(args[1], kukit.E);
         }
         var formvarname = kukit.dom.getRecursiveAttribute(node, argname,
             recurseParents, kukit.dom.getKssAttribute);
@@ -191,7 +190,7 @@
         if (args.length == 2) {
             recurseParents = args[1];
 ;;;         kukit.E = '2nd attribute of nodeAttr must be a boolean.';
-            kukit.ut.evalBool(recurseParents, kukit.E);
+            recurseParents = kukit.ut.evalBool(recurseParents, kukit.E);
         }
         return kukit.dom.getRecursiveAttribute(node, argname, recurseParents,
             kukit.dom.getAttribute);
@@ -219,7 +218,7 @@
         if (args.length == 2) {
             recurseParents = args[1];
 ;;;         kukit.E = '2nd attribute of kssAttr must be a boolean.';
-            kukit.ut.evalBool(recurseParents, kukit.E);
+            recurseParents = kukit.ut.evalBool(recurseParents, kukit.E);
         }
         return kukit.dom.getRecursiveAttribute(node, argname, recurseParents,
             kukit.dom.getKssAttribute);
@@ -287,7 +286,7 @@
 kukit.pr.KssValuePP = function() {};
 kukit.pr.KssValuePP.prototype = {
     check: function(args) {
-;;;     if (args.length != 1 && args.length != 2) {
+;;;     if (args.length != 2 && args.length != 3) {
 ;;;         kukit.E = 'kssValue provider needs 2 or 3 argument (keytype, key,';
 ;;;         kukit.E += ' [recurseParents]).';
 ;;;         throw new Error(kukit.E);
@@ -311,12 +310,49 @@
         if (args.length == 3) {
             recurseParents = args[2];
 ;;;         kukit.E = '3rd attribute of kssAttr must be a boolean.';
-            kukit.ut.evalBool(recurseParents, kukit.E);
+            recurseParents = kukit.ut.evalBool(recurseParents, kukit.E);
         }
-        return kukit.dom.getRecursiveAttribute(node, argname, recurseParents,
-            kukit.dom.getKssValue);
+        return kukit.dom.locateMarkup(node, recurseParents, 
+                kukit.dom.getKssValue, 
+                keytype, key).value;
+
     }
 };
 kukit.pprovidersGlobalRegistry.register('kssValue', kukit.pr.KssValuePP);
 
+kukit.pr.KssIdOfValuePP = function() {};
+kukit.pr.KssIdOfValuePP.prototype = {
+    check: function(args) {
+;;;     if (args.length != 2) {
+;;;         kukit.E = 'kssIdOfValue provider needs 2 arguments (keytype, key).';
+;;;         throw new Error(kukit.E);
+;;;     }
+    },
+    eval: function(args, node) {
+        var keytype =  args[0];
+        var key =  args[1];
+;;;     if (keytype.match(/[ -]/)) {
+;;;         kukit.E = 'keytype parameter in kssIdOfValue provider cannot contain';
+;;;         kukit.E += ' dashes or spaces.';
+;;;         throw new Error(kukit.E);
+;;;     }
+;;;     if (key.match(/[ -]/)) {
+;;;         kukit.E = 'key parameter in kssIdOfValue provider cannot contain';
+;;;         kukit.E += ' dashes or spaces.';
+;;;         throw new Error(kukit.E);
+;;;     }
+        var markup = kukit.dom.locateMarkup(node, true, 
+                kukit.dom.getKssValue, 
+                keytype, key);
+        // return the id of the node where the markup is found
+        var id = markup.node.idd;
+        if (typeof(id) == 'undefined') {
+            // notfound arguments will get null
+            id = null;
+        }
+        return id;
+    }
+};
+kukit.pprovidersGlobalRegistry.register('kssIdOfValue', kukit.pr.KssIdOfValuePP);
+
 


More information about the Kukit-checkins mailing list