source: frontend/node_modules/postcss-initial/index.js

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

Fix frontend appearance

  • Property mode set to 100644
File size: 1.0 KB
Line 
1var makeFallbackFunction = require('./lib/rules-fabric');
2
3module.exports = function postcssInitial(opts) {
4 opts = opts || {};
5 opts.reset = opts.reset || 'all';
6 opts.replace = opts.replace || false;
7 var getFallback = makeFallbackFunction(opts.reset === 'inherited');
8 var getPropPrevTo = function (prop, decl) {
9 var foundPrev = false;
10 decl.parent.walkDecls(function (child) {
11 if (child.prop === decl.prop && child.value !== decl.value) {
12 foundPrev = true;
13 }
14 });
15 return foundPrev;
16 };
17
18 return {
19 postcssPlugin: 'postcss-initial',
20 Declaration: function (decl) {
21 if (!/\binitial\b/.test(decl.value)) {
22 return;
23 }
24 var fallBackRules = getFallback(decl.prop, decl.value);
25 if (fallBackRules.length === 0) return;
26 fallBackRules.forEach(function (rule) {
27 if ( !getPropPrevTo(decl.prop, decl) ) {
28 decl.cloneBefore(rule);
29 }
30 });
31 if (opts.replace === true) {
32 decl.remove();
33 }
34 }
35 };
36};
37
38module.exports.postcss = true;
Note: See TracBrowser for help on using the repository browser.