source: frontend/node_modules/stylehacks/src/plugins/starHtml.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.3 KB
RevLine 
[9af201e]1'use strict';
2const parser = require('postcss-selector-parser');
3const exists = require('../exists');
4const isMixin = require('../isMixin');
5const BasePlugin = require('../plugin');
6const { IE_5_5, IE_6 } = require('../dictionary/browsers');
7const { SELECTOR } = require('../dictionary/identifiers');
8const { RULE } = require('../dictionary/postcss');
9const { HTML } = require('../dictionary/tags');
10
11module.exports = class StarHtml extends BasePlugin {
12 /** @param {import('postcss').Result=} result */
13 constructor(result) {
14 super([IE_5_5, IE_6], [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, '*') &&
37 exists(selector, 1, ' ') &&
38 exists(selector, 2, HTML) &&
39 exists(selector, 3, ' ') &&
40 selector.at(4)
41 ) {
42 this.push(rule, {
43 identifier: SELECTOR,
44 hack: selector.toString(),
45 });
46 }
47 });
48 };
49 }
50};
Note: See TracBrowser for help on using the repository browser.