UNPKG

postcss-merge-longhand

Version:

Merge longhand properties into shorthand with PostCSS.

25 lines (20 loc) • 749 B
import { insertAfter } from './deferredChildEdits.js'; import { inheritSupport } from './isFallback.js'; /** * @param {import('postcss').Container} rule * @param {import('postcss').Declaration} decl * @param {Partial<import('postcss').DeclarationProps>=} props * @return {import('postcss').Declaration} */ function insertCloned(rule, decl, props) { const newNode = Object.assign(decl.clone(), props); if (props?.value !== undefined || props?.prop !== undefined) { delete newNode.raws.value; } insertAfter(rule, decl, newNode); // Propagate support context so cloned longhands preserve the // original declaration's applicability constraints. inheritSupport(decl, newNode); return newNode; } export default insertCloned;