UNPKG

710 BJavaScriptView Raw
1'use strict';
2
3const beforeBlockString = require('./beforeBlockString');
4const hasBlock = require('./hasBlock');
5const rawNodeString = require('./rawNodeString');
6
7/** @typedef {import('postcss').Rule} Rule */
8/** @typedef {import('postcss').AtRule} AtRule */
9
10/**
11 * Return a CSS statement's block -- the string that starts and `{` and ends with `}`.
12 *
13 * If the statement has no block (e.g. `@import url(foo.css);`),
14 * return false.
15 *
16 * @param {Rule | AtRule} statement - postcss rule or at-rule node
17 * @return {string | boolean}
18 */
19module.exports = function (statement) {
20 if (!hasBlock(statement)) {
21 return false;
22 }
23
24 return rawNodeString(statement).slice(beforeBlockString(statement).length);
25};