postcss-normalize-string 5.0.2 → 5.0.3
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/dist/index.js +23 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -230,11 +230,17 @@ function normalize(value, preferredQuote) {
|
|
|
230
230
|
}).toString();
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
233
|
+
function minify(original, cache, preferredQuote) {
|
|
234
|
+
const key = original + '|' + preferredQuote;
|
|
235
|
+
|
|
236
|
+
if (cache.has(key)) {
|
|
237
|
+
return cache.get(key);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const newValue = normalize(original, preferredQuote);
|
|
241
|
+
cache.set(key, newValue);
|
|
242
|
+
return newValue;
|
|
243
|
+
}
|
|
238
244
|
|
|
239
245
|
function pluginCreator(opts) {
|
|
240
246
|
const {
|
|
@@ -248,22 +254,18 @@ function pluginCreator(opts) {
|
|
|
248
254
|
OnceExit(css) {
|
|
249
255
|
const cache = new Map();
|
|
250
256
|
css.walk(node => {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const newValue = normalize(node[param], preferredQuote);
|
|
265
|
-
node[param] = newValue;
|
|
266
|
-
cache.set(key, newValue);
|
|
257
|
+
switch (node.type) {
|
|
258
|
+
case 'rule':
|
|
259
|
+
node.selector = minify(node.selector, cache, preferredQuote);
|
|
260
|
+
break;
|
|
261
|
+
|
|
262
|
+
case 'decl':
|
|
263
|
+
node.value = minify(node.value, cache, preferredQuote);
|
|
264
|
+
break;
|
|
265
|
+
|
|
266
|
+
case 'atrule':
|
|
267
|
+
node.params = minify(node.params, cache, preferredQuote);
|
|
268
|
+
break;
|
|
267
269
|
}
|
|
268
270
|
});
|
|
269
271
|
}
|