postcss-normalize-string
Advanced tools
Comparing version
@@ -72,2 +72,3 @@ 'use strict'; | ||
} | ||
return str + value; | ||
@@ -95,2 +96,3 @@ }, ''); | ||
code = str.charCodeAt(pos); | ||
switch (code) { | ||
@@ -102,2 +104,3 @@ case SPACE: | ||
next = pos; | ||
do { | ||
@@ -126,2 +129,3 @@ next += 1; | ||
next = pos + 1; | ||
if (str.charCodeAt(next) === SINGLE_QUOTE) { | ||
@@ -175,2 +179,3 @@ ast.nodes.push(T_ESCAPED_SINGLE_QUOTE); | ||
const { types } = ast; | ||
if (types[C_SINGLE_QUOTE] || types[C_DOUBLE_QUOTE]) { | ||
@@ -192,5 +197,7 @@ return; | ||
} | ||
if (child.type === C_ESCAPED_SINGLE_QUOTE && node.quote === L_DOUBLE_QUOTE) { | ||
return [...newAst, T_SINGLE_QUOTE]; | ||
} | ||
return [...newAst, child]; | ||
@@ -204,2 +211,3 @@ }, []); | ||
} | ||
return (0, _postcssValueParser2.default)(value).walk(child => { | ||
@@ -209,3 +217,5 @@ if (child.type !== C_STRING) { | ||
} | ||
const ast = parse(child.value); | ||
if (ast.quotes) { | ||
@@ -218,2 +228,3 @@ changeWrappingQuotes(child, ast); | ||
} | ||
child.value = stringify(ast); | ||
@@ -235,7 +246,21 @@ }).toString(); | ||
return css => { | ||
const cache = {}; | ||
css.walk(node => { | ||
const { type } = node; | ||
if ((0, _has2.default)(params, type)) { | ||
const param = params[type]; | ||
node[param] = normalize(node[param], preferredQuote); | ||
const key = node[param] + '|' + preferredQuote; | ||
if (cache[key]) { | ||
node[param] = cache[key]; | ||
return; | ||
} | ||
const result = normalize(node[param], preferredQuote); | ||
node[param] = result; | ||
cache[key] = result; | ||
} | ||
@@ -242,0 +267,0 @@ }); |
{ | ||
"name": "postcss-normalize-string", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Normalize wrapping quotes for CSS string literals.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9983
1.94%207
4.02%0
-100%4
-20%