postcss-ordered-values
Advanced tools
Comparing version 7.0.0 to 7.0.1
{ | ||
"name": "postcss-ordered-values", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "Ensure values are ordered consistently in your CSS.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -6,6 +6,7 @@ 'use strict'; | ||
const getValue = require('../lib/getValue'); | ||
const mathFunctions = require('../lib/mathfunctions.js'); | ||
// animation: [ none | <keyframes-name> ] || <time> || <single-timing-function> || <time> || <single-animation-iteration-count> || <single-animation-direction> || <single-animation-fill-mode> || <single-animation-play-state> | ||
const functions = new Set(['steps', 'cubic-bezier', 'frames']); | ||
const keywords = new Set([ | ||
const timingFunctions = new Set(['steps', 'cubic-bezier', 'frames']); | ||
const timingKeywords = new Set([ | ||
'ease', | ||
@@ -32,7 +33,31 @@ 'ease-in', | ||
* @param {string} value | ||
* @param {string} type | ||
* @param {import('postcss-value-parser').Node} node | ||
* @return {false | import('postcss-value-parser').Dimension} | ||
*/ | ||
function unitFromNode(value, node) { | ||
if (node.type !== 'function') { | ||
return unit(value); | ||
} | ||
if (mathFunctions.has(value)) { | ||
// If it is a math function, it checks the unit of the parameter and returns it. | ||
for (const param of node.nodes) { | ||
const paramUnit = unitFromNode(param.value.toLowerCase(), param); | ||
if (paramUnit && paramUnit.unit && paramUnit.unit !== '%') { | ||
return paramUnit; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
/** | ||
* @param {string} value | ||
* @param {import('postcss-value-parser').Node} node | ||
* @return {boolean} | ||
*/ | ||
const isTimingFunction = (value, type) => { | ||
return (type === 'function' && functions.has(value)) || keywords.has(value); | ||
const isTimingFunction = (value, { type }) => { | ||
return ( | ||
(type === 'function' && timingFunctions.has(value)) || | ||
timingKeywords.has(value) | ||
); | ||
}; | ||
@@ -62,6 +87,7 @@ /** | ||
* @param {string} value | ||
* @param {import('postcss-value-parser').Node} node | ||
* @return {boolean} | ||
*/ | ||
const isTime = (value) => { | ||
const quantity = unit(value); | ||
const isTime = (value, node) => { | ||
const quantity = unitFromNode(value, node); | ||
@@ -72,6 +98,7 @@ return quantity && timeUnits.has(quantity.unit); | ||
* @param {string} value | ||
* @param {import('postcss-value-parser').Node} node | ||
* @return {boolean} | ||
*/ | ||
const isIterationCount = (value) => { | ||
const quantity = unit(value); | ||
const isIterationCount = (value, node) => { | ||
const quantity = unitFromNode(value, node); | ||
@@ -120,3 +147,3 @@ return value === 'infinite' || (quantity && !quantity.unit); | ||
const hasMatch = stateConditions.some(({ property, delegate }) => { | ||
if (delegate(value, type) && !state[property].length) { | ||
if (delegate(value, node) && !state[property].length) { | ||
state[property] = [node, addSpace()]; | ||
@@ -123,0 +150,0 @@ return true; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32364
897