[js] add a selector string escaping function
will help use id strings in jquery selector expressions, e.g:
"foo.[subject]:42" -> "foo\.\[subject\]\:42"
Related to #3154531.
--- 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);