| 1 |
// CSS escapes |
| 2 |
// https://www.w3.org/TR/CSS21/syndata.html#escaped-characters |
| 3 |
import { whitespace } from "../var/whitespace.js"; |
| 4 |
|
| 5 |
var runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + |
| 6 |
"?|\\\\([^\\r\\n\\f])", "g" ), |
| 7 |
funescape = function( escape, nonHex ) { |
| 8 |
var high = "0x" + escape.slice( 1 ) - 0x10000; |
| 9 |
|
| 10 |
if ( nonHex ) { |
| 11 |
|
| 12 |
// Strip the backslash prefix from a non-hex escape sequence |
| 13 |
return nonHex; |
| 14 |
} |
| 15 |
|
| 16 |
// Replace a hexadecimal escape sequence with the encoded Unicode code point |
| 17 |
// Support: IE <=11+ |
| 18 |
// For values outside the Basic Multilingual Plane (BMP), manually construct a |
| 19 |
// surrogate pair |
| 20 |
return high < 0 ? |
| 21 |
String.fromCharCode( high + 0x10000 ) : |
| 22 |
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); |
| 23 |
}; |
| 24 |
|
| 25 |
export function unescapeSelector( sel ) { |
| 26 |
return sel.replace( runescape, funescape ); |
| 27 |
} |