source: frontend/node_modules/postcss-merge-longhand/src/lib/canMerge.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.0 KB
Line 
1'use strict';
2const isCustomProp = require('./isCustomProp');
3
4/** @type {(node: import('postcss').Declaration) => boolean} */
5const important = (node) => node.important;
6/** @type {(node: import('postcss').Declaration) => boolean} */
7const unimportant = (node) => !node.important;
8
9/* Cannot be combined with other values in shorthand
10 https://www.w3.org/TR/css-cascade-5/#shorthand */
11const cssWideKeywords = ['inherit', 'initial', 'unset', 'revert'];
12/**
13 * @type {(props: import('postcss').Declaration[], includeCustomProps?: boolean) => boolean}
14 */
15module.exports = (props, includeCustomProps = true) => {
16 const uniqueProps = new Set(props.map((node) => node.value.toLowerCase()));
17
18 if (uniqueProps.size > 1) {
19 for (const unmergeable of cssWideKeywords) {
20 if (uniqueProps.has(unmergeable)) {
21 return false;
22 }
23 }
24 }
25
26 if (
27 includeCustomProps &&
28 props.some(isCustomProp) &&
29 !props.every(isCustomProp)
30 ) {
31 return false;
32 }
33
34 return props.every(unimportant) || props.every(important);
35};
Note: See TracBrowser for help on using the repository browser.