Less: Fix incorrect comment in selector() (#8707)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-07-06 17:48:30 +08:00
1 parent 8ab93b4454
commit 0998366d41
4 files changed
+51

No files matched your search

+18
View File
@@ -20,6 +20,7 @@ const {
indent,
dedent,
ifBreak,
breakParent,
},
utils: { removeLines },
} = require("../document");
@@ -501,6 +502,23 @@ function genericPrint(path, options, print) {
return options.originalText.slice(start, end).trim();
}
// Same reason above
const grandParent = path.getParentNode(1);
if (
parentNode.type === "value-paren_group" &&
grandParent &&
grandParent.type === "value-func" &&
grandParent.value === "selector"
) {
const start = options.locStart(parentNode.open) + 1;
const end = options.locEnd(parentNode.close) - 1;
const selector = options.originalText.slice(start, end).trim();
return lastLineHasInlineComment(selector)
? concat([breakParent, selector])
: selector;
}
return node.value;
}
// postcss-values-parser
@@ -0,0 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`selector.less format 1`] = `
====================================options=====================================
parsers: ["less"]
printWidth: 80
| printWidth
=====================================input======================================
@supports selector(
:focus-visible // *"a"
) {
a{color:#f00
}
}
=====================================output=====================================
@supports selector(
:focus-visible // *"a"
) {
a {
color: #f00;
}
}
================================================================================
`;
@@ -0,0 +1 @@
run_spec(__dirname, ["less"]);
@@ -0,0 +1,6 @@
@supports selector(
:focus-visible // *"a"
) {
a{color:#f00
}
}