Remove extra indentation in pseudo class function (#16572)
This commit is contained in:
1 parent
3cf3f5ac29
commit
1dfe28f857
4 files changed
+144
-2
No files matched your search
@@ -0,0 +1,30 @@
|
||||
#### Remove extra indentation in pseudo-class function (#16572 by @sosukesuzuki)
|
||||
|
||||
This change fixes a bug where extra indentation was added when line breaks were included in the argument list of pseudo-class functions like [`:where()`](https://developer.mozilla.org/en-US/docs/Web/CSS/:where), [`:is()`](https://developer.mozilla.org/en-US/docs/Web/CSS/:is), and [`:not`](https://developer.mozilla.org/en-US/docs/Web/CSS/:not).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```css
|
||||
/* Input */
|
||||
:where(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
/* Prettier stable */
|
||||
:where(
|
||||
input:not([type="button"], [type="reset"], [type="submit"]),
|
||||
textarea,
|
||||
select
|
||||
) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
/* Prettier main */
|
||||
:where(
|
||||
input:not([type="button"], [type="reset"], [type="submit"]),
|
||||
textarea,
|
||||
select
|
||||
) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
```
|
||||
@@ -357,8 +357,12 @@ function genericPrint(path, options, print) {
|
||||
),
|
||||
]);
|
||||
|
||||
case "selector-selector":
|
||||
return group(indent(path.map(print, "nodes")));
|
||||
case "selector-selector": {
|
||||
const shouldIndent = node.nodes.length > 1;
|
||||
return group(
|
||||
(shouldIndent ? indent : (x) => x)(path.map(print, "nodes")),
|
||||
);
|
||||
}
|
||||
|
||||
case "selector-comment":
|
||||
return node.value;
|
||||
|
||||
@@ -1,5 +1,90 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`indent.css format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["css"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
:where(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
.foooooooooooooooooooo :where(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
:is(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
.foooooooooooooooooooo :is(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
:not(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
.foooooooooooooooooooo :not(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
:where(
|
||||
input:not([type="button"], [type="reset"], [type="submit"]),
|
||||
textarea,
|
||||
select
|
||||
) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
.foooooooooooooooooooo
|
||||
:where(
|
||||
input:not([type="button"], [type="reset"], [type="submit"]),
|
||||
textarea,
|
||||
select
|
||||
) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
:is(
|
||||
input:not([type="button"], [type="reset"], [type="submit"]),
|
||||
textarea,
|
||||
select
|
||||
) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
.foooooooooooooooooooo
|
||||
:is(
|
||||
input:not([type="button"], [type="reset"], [type="submit"]),
|
||||
textarea,
|
||||
select
|
||||
) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
:not(
|
||||
input:not([type="button"], [type="reset"], [type="submit"]),
|
||||
textarea,
|
||||
select
|
||||
) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
.foooooooooooooooooooo
|
||||
:not(
|
||||
input:not([type="button"], [type="reset"], [type="submit"]),
|
||||
textarea,
|
||||
select
|
||||
) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`is.css format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["css"]
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
:where(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
.foooooooooooooooooooo :where(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
:is(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
.foooooooooooooooooooo :is(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
:not(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
|
||||
.foooooooooooooooooooo :not(input:not([type="button"], [type="reset"], [type="submit"]), textarea, select) {
|
||||
/* CSS here */
|
||||
}
|
||||
Reference in new issue
Block a user