Urara-Blog/node_modules/.pnpm-store/v3/files/94/cb66ca4f860c1ef1093ff4192e76fa5f0d39edf3d8ebb43e99cbb238814ae1cf68433b845072be636e8a3b68a924fe845d45150d2a80ef48604a775b99fc38
2022-08-14 01:14:53 +08:00

35 lines
1 KiB
Text

'use strict';
const isCustomProp = require('./isCustomProp');
/** @type {(node: import('postcss').Declaration) => boolean} */
const important = (node) => node.important;
/** @type {(node: import('postcss').Declaration) => boolean} */
const unimportant = (node) => !node.important;
/* Cannot be combined with other values in shorthand
https://www.w3.org/TR/css-cascade-5/#shorthand */
const cssWideKeywords = ['inherit', 'initial', 'unset', 'revert'];
/**
* @type {(props: import('postcss').Declaration[], includeCustomProps?: boolean) => boolean}
*/
module.exports = (props, includeCustomProps = true) => {
const uniqueProps = new Set(props.map((node) => node.value.toLowerCase()));
if (uniqueProps.size > 1) {
for (const unmergeable of cssWideKeywords) {
if (uniqueProps.has(unmergeable)) {
return false;
}
}
}
if (
includeCustomProps &&
props.some(isCustomProp) &&
!props.every(isCustomProp)
) {
return false;
}
return props.every(unimportant) || props.every(important);
};