postcss-merge-longhand
Version:
Merge longhand properties into shorthand with PostCSS.
20 lines (17 loc) • 530 B
JavaScript
/**
* Returns all declarations for the given CSS properties.
*
* @param {import('postcss').Rule} rule
* @param {Set<string>} properties the CSS properties to search for
* @return {Set<import('postcss').Declaration>}
*/
function getDeclarationsThatMatchProperties(rule, properties) {
const decls = new Set();
for (const node of rule.nodes) {
if (node.type === 'decl' && properties.has(node.prop.toLowerCase())) {
decls.add(node);
}
}
return decls;
}
export default getDeclarationsThatMatchProperties;