Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(postcss-merge-rules): add some missing known pseudo classes. #1099

Merged
merged 1 commit into from May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/postcss-merge-rules/src/__tests__/index.js
Expand Up @@ -807,3 +807,11 @@ test(
'a{color : green;} a:focus-visible{ color : green;} a:focus-visible{ background : red}'
)
);

test(
'should merge :visited and :link pseudo-classes',
processCSS(
'a,a:link{color:#555}a:visited{color:#555}',
'a,a:link,a:visited{color:#555}'
)
);
8 changes: 8 additions & 0 deletions packages/postcss-merge-rules/src/lib/ensureCompatibility.js
Expand Up @@ -10,6 +10,7 @@ const cssGencontent = 'css-gencontent';
const cssFirstLetter = 'css-first-letter';
const cssFirstLine = 'css-first-line';
const cssInOutOfRange = 'css-in-out-of-range';
const formValidation = 'form-validation';

/** @type {string[]} */
const prefixes = vendors.map((v) => `-${v}-`);
Expand Down Expand Up @@ -47,6 +48,7 @@ export function noVendor(selector) {
export const pseudoElements = {
':active': cssSel2,
':after': cssGencontent,
':any-link': 'css-any-link',
':before': cssGencontent,
':checked': cssSel3,
':default': 'css-default-pseudo',
Expand All @@ -65,9 +67,12 @@ export const pseudoElements = {
':hover': cssSel2,
':in-range': cssInOutOfRange,
':indeterminate': 'css-indeterminate-pseudo',
':invalid': formValidation,
':is': 'css-matches-pseudo',
':lang': cssSel2,
':last-child': cssSel3,
':last-of-type': cssSel3,
':link': cssSel2,
':matches': 'css-matches-pseudo',
':not': cssSel3,
':nth-child': cssSel3,
Expand All @@ -79,6 +84,7 @@ export const pseudoElements = {
':optional': 'css-optional-pseudo',
':out-of-range': cssInOutOfRange,
':placeholder-shown': 'css-placeholder-shown',
':required': formValidation,
':root': cssSel3,
':target': cssSel3,
'::after': cssGencontent,
Expand All @@ -89,6 +95,8 @@ export const pseudoElements = {
'::marker': 'css-marker-pseudo',
'::placeholder': 'css-placeholder',
'::selection': 'css-selection',
':valid': formValidation,
':visited': cssSel2,
};

function isCssMixin(selector) {
Expand Down