beforeBlockString.js 625 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const { isAtRule, isRule } = require('./typeGuards');
  3. /**
  4. * @param {import('postcss').Container} statement
  5. * @returns {string}
  6. */
  7. module.exports = function beforeBlockString(statement, { noRawBefore } = { noRawBefore: false }) {
  8. let result = '';
  9. const before = statement.raws.before || '';
  10. if (!noRawBefore) {
  11. result += before;
  12. }
  13. if (isRule(statement)) {
  14. result += statement.selector;
  15. } else if (isAtRule(statement)) {
  16. result += `@${statement.name}${statement.raws.afterName || ''}${statement.params}`;
  17. } else {
  18. return '';
  19. }
  20. result += statement.raws.between || '';
  21. return result;
  22. };