isCustomPropertySet.js 430 B

123456789101112131415161718
  1. 'use strict';
  2. const _ = require('lodash');
  3. const hasBlock = require('../utils/hasBlock');
  4. /**
  5. * Check whether a Node is a custom property set
  6. *
  7. * @param {import('postcss').Rule} node
  8. * @returns {boolean}
  9. */
  10. module.exports = function (node) {
  11. const selector = _.get(node, 'raws.selector.raw', node.selector);
  12. return (
  13. node.type === 'rule' && hasBlock(node) && selector.startsWith('--') && selector.endsWith(':')
  14. );
  15. };