Manipulation: Support $el.html(selfRemovingScript) (#5378)
[jquery.git] / src / selector / unescapeSelector.js
blob05c1d9e7612acf07af78b65978245361e0704d39
1 // CSS escapes
2 // https://www.w3.org/TR/CSS21/syndata.html#escaped-characters
3 import { whitespace } from "../var/whitespace.js";
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;
10                 if ( nonHex ) {
12                         // Strip the backslash prefix from a non-hex escape sequence
13                         return nonHex;
14                 }
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         };
25 export function unescapeSelector( sel ) {
26         return sel.replace( runescape, funescape );