Skip to content

Commit

Permalink
fix: temporarily add changes from cssnano#1572 until merged
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Mar 4, 2024
1 parent 7ed2649 commit 3e4443c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/postcss-reduce-initial/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ const browserslist = require('browserslist');
const { isSupported } = require('caniuse-api');
const fromInitial = require('./data/fromInitial.json');
const toInitial = require('./data/toInitial.json');
const ignoreProps = require('./lib/ignoreProps.js');

const initial = 'initial';

// In most of the browser including chrome the initial for `writing-mode` is not `horizontal-tb`. Ref https://github.com/cssnano/cssnano/pull/905
const defaultIgnoreProps = ['writing-mode', 'transform-box'];
const defaultIgnoreProps = ignoreProps;

/**
* @typedef {Pick<browserslist.Options, 'stats' | 'env'>} BrowserslistOptions
Expand Down
2 changes: 2 additions & 0 deletions packages/postcss-reduce-initial/src/lib/ignoreProps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
module.exports = ['writing-mode', 'transform-box'];
11 changes: 7 additions & 4 deletions packages/postcss-reduce-initial/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {

const fromInitial = require('../src/data/fromInitial.json');
const toInitial = require('../src/data/toInitial.json');
const ignoreProps = require('../src/lib/ignoreProps.js');
const plugin = require('../src/index.js');

const { processCSS, passthroughCSS } = processCSSFactory(plugin);
Expand All @@ -15,13 +16,15 @@ function convertInitial(property, value) {
return processCSS(`${property}:initial`, `${property}:${value}`);
}

function convertToInitial(t, property, value) {
function convertToInitial(property, value) {
const output = ignoreProps.includes(property) ? value : 'initial';

return () =>
Promise.all([
processCSS(t, `${property}:${value}`, `${property}:initial`, {
processCSS(`${property}:${value}`, `${property}:${output}`, {
env: 'chrome58',
}),
passthroughCSS(t, `${property}:${value}`, { env: 'ie6' }),
})(),
passthroughCSS(`${property}:${value}`, { env: 'ie6' })(),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-reduce-initial/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../../tsconfig.json",
"include": ["src/*", "src/data/fromInitial.json", "src/data/toInitial.json"],
"include": ["src/*", "src/lib/*", "src/data/fromInitial.json", "src/data/toInitial.json"],
"compilerOptions": {
"composite": true,
"rootDir": "src/",
Expand Down
2 changes: 2 additions & 0 deletions packages/postcss-reduce-initial/types/lib/ignoreProps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _exports: string[];
export = _exports;

0 comments on commit 3e4443c

Please sign in to comment.