File size: 430 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
const rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|^-|[^\x80-\uFFFF\w-]/g
const fcssescape = function (ch: string, asCodePoint: string) {
  if (!asCodePoint) return "\\" + ch
  if (ch === "\0") return "\uFFFD"
  if (ch === "-" && ch.length === 1) return "\\-"
  return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + ""
}
export const esc = (sel: string) => {
  return (sel + "").replace(rcssescape, fcssescape)
}