source: frontend/node_modules/stylehacks/src/plugins/bodyEmpty.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2const parser = require('postcss-selector-parser');
3const exists = require('../exists');
4const isMixin = require('../isMixin');
5const BasePlugin = require('../plugin');
6const { FF_2 } = require('../dictionary/browsers');
7const { SELECTOR } = require('../dictionary/identifiers');
8const { RULE } = require('../dictionary/postcss');
9const { BODY } = require('../dictionary/tags');
10
11module.exports = class BodyEmpty extends BasePlugin {
12 /** @param {import('postcss').Result} result */
13 constructor(result) {
14 super([FF_2], [RULE], result);
15 }
16
17 /**
18 * @param {import('postcss').Rule} rule
19 * @return {void}
20 */
21 detect(rule) {
22 if (isMixin(rule)) {
23 return;
24 }
25 parser(this.analyse(rule)).processSync(rule.selector);
26 }
27
28 /**
29 * @param {import('postcss').Rule} rule
30 * @return {parser.SyncProcessor<void>}
31 */
32 analyse(rule) {
33 return (selectors) => {
34 selectors.each((selector) => {
35 if (
36 exists(selector, 0, BODY) &&
37 exists(selector, 1, ':empty') &&
38 exists(selector, 2, ' ') &&
39 selector.at(3)
40 ) {
41 this.push(rule, {
42 identifier: SELECTOR,
43 hack: selector.toString(),
44 });
45 }
46 });
47 };
48 }
49};
Note: See TracBrowser for help on using the repository browser.