|
@@ -14,6 +14,8 @@
|
|
|
|
|
|
|
|
// Modified by Gildas Lormeau
|
|
// Modified by Gildas Lormeau
|
|
|
|
|
|
|
|
|
|
+/* global CSS */
|
|
|
|
|
+
|
|
|
this.cssWhat = this.cssWhat || (() => {
|
|
this.cssWhat = this.cssWhat || (() => {
|
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
|
@@ -112,48 +114,16 @@ this.cssWhat = this.cssWhat || (() => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
function escapeName(str) {
|
|
function escapeName(str) {
|
|
|
- return cssEscape(str).output;
|
|
|
|
|
|
|
+ return CSS.escape(str);
|
|
|
}
|
|
}
|
|
|
return stringify;
|
|
return stringify;
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
- const REGEXP_STARTS_DASH_DECIMAL = /^-[\d]/;
|
|
|
|
|
-
|
|
|
|
|
return {
|
|
return {
|
|
|
parse,
|
|
parse,
|
|
|
stringify
|
|
stringify
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // cssEscape taken from https://mathiasbynens.be/notes/css-escapes
|
|
|
|
|
- function cssEscape(string) {
|
|
|
|
|
- const firstChar = string.charAt(0);
|
|
|
|
|
- const length = string.length;
|
|
|
|
|
- let output = "", counter = 0;
|
|
|
|
|
- while (counter < length) {
|
|
|
|
|
- let value;
|
|
|
|
|
- const character = string.charAt(counter++);
|
|
|
|
|
- if (character == "\t" || character == "\n" || character == "\v" || character == "\f" || character == ":") {
|
|
|
|
|
- value = "\\" + character.charCodeAt().toString(16).toUpperCase() + " ";
|
|
|
|
|
- } else if (character == "[" || character == " " || character == "!" || character == "\"" || character == "#" || character == "$" || character == "%" || character == "&" || character == "'" || character == "(" || character == ")" || character == "*" || character == "+" || character == "," || character == "." || character == "/" || character == ";" || character == "<" || character == "=" || character == ">" || character == "?" || character == "@" || character == "[" || character == "\\" || character == "]" || character == "^" || character == "`" || character == "{," || character == "|" || character == "}" || character == "~" || character == "]") {
|
|
|
|
|
- value = "\\" + character;
|
|
|
|
|
- } else {
|
|
|
|
|
- value = character;
|
|
|
|
|
- }
|
|
|
|
|
- output += value;
|
|
|
|
|
- }
|
|
|
|
|
- if (output.startsWith("_")) {
|
|
|
|
|
- output = "\\_" + output.slice(1);
|
|
|
|
|
- } else if (output.match(REGEXP_STARTS_DASH_DECIMAL)) {
|
|
|
|
|
- output = "\\-" + output.slice(1);
|
|
|
|
|
- }
|
|
|
|
|
- if (firstChar == "0" || firstChar == "1" || firstChar == "2" || firstChar == "3" || firstChar == "4" || firstChar == "5" || firstChar == "6" || firstChar == "7" || firstChar == "8" || firstChar == "9") {
|
|
|
|
|
- output = "\\3" + firstChar + " " + output.slice(1);
|
|
|
|
|
- }
|
|
|
|
|
- return {
|
|
|
|
|
- "output": output
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// unescape function taken from https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L139
|
|
// unescape function taken from https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L139
|
|
|
function funescape(_, escaped, escapedWhitespace) {
|
|
function funescape(_, escaped, escapedWhitespace) {
|
|
|
const high = "0x" + escaped - 0x10000;
|
|
const high = "0x" + escaped - 0x10000;
|