|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 | const BasePlugin = require('../plugin');
|
|---|
| 3 | const { IE_6 } = require('../dictionary/browsers');
|
|---|
| 4 | const { PROPERTY } = require('../dictionary/identifiers');
|
|---|
| 5 | const { DECL } = require('../dictionary/postcss');
|
|---|
| 6 |
|
|---|
| 7 | /**
|
|---|
| 8 | * @param {string} prop
|
|---|
| 9 | * @return {string}
|
|---|
| 10 | */
|
|---|
| 11 | function vendorPrefix(prop) {
|
|---|
| 12 | let match = prop.match(/^(-\w+-)/);
|
|---|
| 13 | if (match) {
|
|---|
| 14 | return match[0];
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | return '';
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | module.exports = class LeadingUnderscore extends BasePlugin {
|
|---|
| 21 | /** @param {import('postcss').Result=} result */
|
|---|
| 22 | constructor(result) {
|
|---|
| 23 | super([IE_6], [DECL], result);
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | /**
|
|---|
| 27 | * @param {import('postcss').Declaration} decl
|
|---|
| 28 | * @return {void}
|
|---|
| 29 | */
|
|---|
| 30 | detect(decl) {
|
|---|
| 31 | const { before } = decl.raws;
|
|---|
| 32 |
|
|---|
| 33 | if (before && before.includes('_')) {
|
|---|
| 34 | this.push(decl, {
|
|---|
| 35 | identifier: PROPERTY,
|
|---|
| 36 | hack: `${before.trim()}${decl.prop}`,
|
|---|
| 37 | });
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | if (
|
|---|
| 41 | decl.prop[0] === '-' &&
|
|---|
| 42 | decl.prop[1] !== '-' &&
|
|---|
| 43 | vendorPrefix(decl.prop) === ''
|
|---|
| 44 | ) {
|
|---|
| 45 | this.push(decl, {
|
|---|
| 46 | identifier: PROPERTY,
|
|---|
| 47 | hack: decl.prop,
|
|---|
| 48 | });
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|
| 51 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.