web/data/cubicweb.js
changeset 9284 4c37808fd284
parent 9259 68cde7431c2c
child 9534 34d9de030564
--- a/web/data/cubicweb.js	Thu Oct 10 13:26:11 2013 +0200
+++ b/web/data/cubicweb.js	Tue Oct 08 14:02:28 2013 +0200
@@ -45,6 +45,15 @@
         return null;
     },
 
+    // escapes string selectors (e.g. "foo.[subject]:42" -> "foo\.\[subject\]\:42"
+    escape: function(selector) {
+        if (typeof(selector) == 'string') {
+            return  selector.replace( /(:|\.|\[|\])/g, "\\$1" );
+        }
+        // cw.log('non string selector', selector);
+        return '';
+    },
+
     getNode: function (node) {
         if (typeof(node) == 'string') {
             return document.getElementById(node);