|
|
@@ -117,6 +117,12 @@ this.cssWhat = this.cssWhat || (() => {
|
|
|
return stringify;
|
|
|
})();
|
|
|
|
|
|
+ const REGEXP_WHITESPACE = /[\t\n\v\f:]/;
|
|
|
+ const REGEXP2 = /[ !"#$%&'()*+,./;<=>?@[\\\]^`{|}~]/;
|
|
|
+ const REGEXP_STARTS_UNDERSCORE = /^_/;
|
|
|
+ const REGEXP_STARTS_DASH_DECIMAL = /^-[\d]/;
|
|
|
+ const REGEXP_DECIMAL = /\d/;
|
|
|
+
|
|
|
return {
|
|
|
parse,
|
|
|
stringify
|
|
|
@@ -141,9 +147,9 @@ this.cssWhat = this.cssWhat || (() => {
|
|
|
}
|
|
|
value = "\\" + charCode.toString(16).toUpperCase() + " ";
|
|
|
} else {
|
|
|
- if (/[\t\n\v\f:]/.test(character)) {
|
|
|
+ if (character.match(REGEXP_WHITESPACE)) {
|
|
|
value = "\\" + charCode.toString(16).toUpperCase() + " ";
|
|
|
- } else if (/[ !"#$%&'()*+,./;<=>?@[\\\]^`{|}~]/.test(character)) {
|
|
|
+ } else if (character.match(REGEXP2)) {
|
|
|
value = "\\" + character;
|
|
|
} else {
|
|
|
value = character;
|
|
|
@@ -151,13 +157,13 @@ this.cssWhat = this.cssWhat || (() => {
|
|
|
}
|
|
|
output += value;
|
|
|
}
|
|
|
- if (/^_/.test(output)) {
|
|
|
+ if (output.match(REGEXP_STARTS_UNDERSCORE)) {
|
|
|
output = "\\_" + output.slice(1);
|
|
|
}
|
|
|
- if (/^-[\d]/.test(output)) {
|
|
|
+ if (output.match(REGEXP_STARTS_DASH_DECIMAL)) {
|
|
|
output = "\\-" + output.slice(1);
|
|
|
}
|
|
|
- if (/\d/.test(firstChar)) {
|
|
|
+ if (firstChar.match(REGEXP_DECIMAL)) {
|
|
|
output = "\\3" + firstChar + " " + output.slice(1);
|
|
|
}
|
|
|
return {
|