@thejaredwilcurt/csslop 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/rules/stringify.js +6 -6
package/package.json
CHANGED
package/src/rules/stringify.js
CHANGED
|
@@ -283,8 +283,8 @@ function stringifyRule (rule, context, nested = false) {
|
|
|
283
283
|
|
|
284
284
|
// Minify double-quoted attribute selectors: remove inner whitespace and escape when shorter
|
|
285
285
|
minified = minified.replace(/\[\s*([^=]+)\s*=\s*"(.*?)"\s*\]/g, (match, attribute, value) => {
|
|
286
|
-
// Escape special characters that require quoting, and compare lengths
|
|
287
|
-
let escaped = value.replace(/([#.:/])/g, '\\$1');
|
|
286
|
+
// Escape special characters that require quoting (spaces, #, ., :, /), and compare lengths
|
|
287
|
+
let escaped = value.replace(/([ #.:/])/g, '\\$1');
|
|
288
288
|
if (escaped.length < value.length + 2) {
|
|
289
289
|
return '[' + attribute + '=' + escaped + ']';
|
|
290
290
|
}
|
|
@@ -292,8 +292,8 @@ function stringifyRule (rule, context, nested = false) {
|
|
|
292
292
|
});
|
|
293
293
|
// Minify single-quoted attribute selectors: remove inner whitespace and escape when shorter
|
|
294
294
|
minified = minified.replace(/\[\s*([^=]+)\s*=\s*'(.*?)'\s*\]/g, (match, attribute, value) => {
|
|
295
|
-
// Escape special characters that require quoting, and compare lengths
|
|
296
|
-
let escaped = value.replace(/([#.:/])/g, '\\$1');
|
|
295
|
+
// Escape special characters that require quoting (spaces, #, ., :, /), and compare lengths
|
|
296
|
+
let escaped = value.replace(/([ #.:/])/g, '\\$1');
|
|
297
297
|
if (escaped.length < value.length + 2) {
|
|
298
298
|
return '[' + attribute + '=' + escaped + ']';
|
|
299
299
|
}
|
|
@@ -301,8 +301,8 @@ function stringifyRule (rule, context, nested = false) {
|
|
|
301
301
|
});
|
|
302
302
|
// Minify unquoted attribute selectors: quote when unescaping produces a shorter result
|
|
303
303
|
minified = minified.replace(/\[\s*([^=]+)\s*=\s*([^"'].*?)\s*\]/g, (match, attribute, value) => {
|
|
304
|
-
// Unescape special characters and compare with quoted form
|
|
305
|
-
let unescaped = value.replace(/\\([#.:/])/g, '$1');
|
|
304
|
+
// Unescape special characters (spaces, #, ., :, /) and compare with quoted form
|
|
305
|
+
let unescaped = value.replace(/\\([ #.:/])/g, '$1');
|
|
306
306
|
if (unescaped.length + 2 < value.length) {
|
|
307
307
|
return '[' + attribute + '="' + unescaped + '"]';
|
|
308
308
|
}
|