postcss-reduce-transforms
Advanced tools
Comparing version 4.0.1 to 4.0.2
@@ -29,2 +29,3 @@ 'use strict'; | ||
} | ||
return list; | ||
@@ -37,2 +38,3 @@ } | ||
const { nodes } = node; | ||
node.value = 'matrix'; | ||
@@ -62,2 +64,3 @@ node.nodes = [nodes[0], // a | ||
const match = rotate3dMatch(values.slice(0, 3)); | ||
if (match.length) { | ||
@@ -76,11 +79,16 @@ node.value = match; | ||
const { nodes } = node; | ||
if (!nodes[2]) { | ||
return; | ||
} | ||
const [first, second] = values; | ||
// scale(sx, sy) => scale(sx) | ||
if (first === second) { | ||
node.nodes = [nodes[0]]; | ||
return; | ||
} | ||
// scale(sx, 1) => scaleX(sx) | ||
@@ -90,4 +98,6 @@ if (second === 1) { | ||
node.nodes = [nodes[0]]; | ||
return; | ||
} | ||
// scale(1, sy) => scaleY(sy) | ||
@@ -97,2 +107,3 @@ if (first === 1) { | ||
node.nodes = [nodes[2]]; | ||
return; | ||
@@ -105,2 +116,3 @@ } | ||
const [first, second, third] = values; | ||
// scale3d(sx, 1, 1) => scaleX(sx) | ||
@@ -110,4 +122,6 @@ if (second === 1 && third === 1) { | ||
node.nodes = [nodes[0]]; | ||
return; | ||
} | ||
// scale3d(1, sy, 1) => scaleY(sy) | ||
@@ -117,4 +131,6 @@ if (first === 1 && third === 1) { | ||
node.nodes = [nodes[2]]; | ||
return; | ||
} | ||
// scale3d(1, 1, sz) => scaleZ(sz) | ||
@@ -124,2 +140,3 @@ if (first === 1 && second === 1) { | ||
node.nodes = [nodes[4]]; | ||
return; | ||
@@ -131,10 +148,14 @@ } | ||
const { nodes } = node; | ||
if (!nodes[2]) { | ||
return; | ||
} | ||
// translate(tx, 0) => translate(tx) | ||
if (values[1] === 0) { | ||
node.nodes = [nodes[0]]; | ||
return; | ||
} | ||
// translate(0, ty) => translateY(ty) | ||
@@ -144,2 +165,3 @@ if (values[0] === 0) { | ||
node.nodes = [nodes[2]]; | ||
return; | ||
@@ -151,2 +173,3 @@ } | ||
const { nodes } = node; | ||
// translate3d(0, 0, tz) => translateZ(tz) | ||
@@ -182,5 +205,7 @@ if (values[0] === 0 && values[1] === 0) { | ||
const normalizedReducerName = normalizeReducerName(value); | ||
if (type === 'function' && (0, _has2.default)(reducers, normalizedReducerName)) { | ||
reducers[normalizedReducerName](node, nodes.reduce(getValues, [])); | ||
} | ||
return false; | ||
@@ -191,4 +216,17 @@ } | ||
return css => { | ||
const cache = {}; | ||
css.walkDecls(/transform$/i, decl => { | ||
decl.value = (0, _postcssValueParser2.default)(decl.value).walk(reduce).toString(); | ||
const value = decl.value; | ||
if (cache[value]) { | ||
decl.value = cache[value]; | ||
return; | ||
} | ||
const result = (0, _postcssValueParser2.default)(value).walk(reduce).toString(); | ||
decl.value = result; | ||
cache[value] = result; | ||
}); | ||
@@ -195,0 +233,0 @@ }; |
{ | ||
"name": "postcss-reduce-transforms", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Reduce transform functions with PostCSS.", | ||
@@ -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
163
0
7732
4