Skip to content

Commit

Permalink
Selector: Allow whitespace after hex escapes in CSS identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Aug 19, 2019
1 parent 9ffbb8b commit b2b650b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 39 deletions.
34 changes: 17 additions & 17 deletions dist/sizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Released under the MIT license
* https://js.foundation/
*
* Date: 2019-05-29
* Date: 2019-07-02
*/
( function( window ) {
var i,
Expand Down Expand Up @@ -76,8 +76,9 @@ var i,
// http://www.w3.org/TR/css3-selectors/#whitespace
whitespace = "[\\x20\\t\\r\\n\\f]",

// http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
// https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",

// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
Expand Down Expand Up @@ -147,22 +148,21 @@ var i,

// CSS escapes
// http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace +
")|.)", "ig" ),
funescape = function( _, escaped, escapedWhitespace ) {
var high = "0x" + escaped - 0x10000;

// NaN means non-codepoint
// Support: Firefox<24
// Workaround erroneous numeric interpretation of +"0x"
return high !== high || escapedWhitespace ?
escaped :
high < 0 ?
runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
funescape = function( escape, nonHex ) {
var high = "0x" + escape.slice( 1 ) - 0x10000;

// BMP codepoint
String.fromCharCode( high + 0x10000 ) :
return nonHex ?

// Strip the backslash prefix from a non-hex escape sequence
nonHex :

// Supplemental Plane codepoint (surrogate pair)
// Replace a hexadecimal escape sequence with the encoded Unicode code point
// Support: IE <=11+
// For values outside the Basic Multilingual Plane (BMP), manually construct a
// surrogate pair
high < 0 ?
String.fromCharCode( high + 0x10000 ) :
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
},

Expand Down
Loading

0 comments on commit b2b650b

Please sign in to comment.