You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Query selectors must use css syntax, which means things like semicolons and backslashes need a backslash to precede them.
Example where this causes failure:
(sel"#:0.inp")
This will produce a SYNTAX_ERR (== DOM Exception 12). The crazy-looking ":0.inp" is the typical format of ids produced by goog.ui.Component/makeId which are regularly inserted into id attributes of dom elements (which is how it bit me).
An at least partial fix is to use an escaping function like this (cljs):
(defrequires-css-escaping#"(?:^[^a-zA-Z]|[\u0000-\u002c\u002e\u002f\u003a-\u0040\u005b-\u005e\u0060\u007b-\u009f])")
(defnescape-css-char [c] (str \\ (.. c (charCodeAt0) (toString16)) \space))
(defncss-escape [s] (clojure.string/replace s requires-css-escaping escape-css-char))
I think dommy.macros/selector will need a similar transformation.
However you can only safely use this on keywords since strings may use css characters for their intended meaning. This argues for making "css-escape" or "selector-escape" a public function users can use.
The text was updated successfully, but these errors were encountered:
Query selectors must use css syntax, which means things like semicolons and backslashes need a backslash to precede them.
Example where this causes failure:
This will produce a
SYNTAX_ERR
(==DOM Exception 12
). The crazy-looking":0.inp"
is the typical format of ids produced bygoog.ui.Component/makeId
which are regularly inserted into id attributes of dom elements (which is how it bit me).An at least partial fix is to use an escaping function like this (cljs):
And then patch
dommy.core/selector
:I think
dommy.macros/selector
will need a similar transformation.However you can only safely use this on keywords since strings may use css characters for their intended meaning. This argues for making "css-escape" or "selector-escape" a public function users can use.
The text was updated successfully, but these errors were encountered: