Add a test with all the less docs and fix issues (#1792)
The docs go over a bunch of edge cases, might as well have it as a test :) http://lesscss.org/features/ I just had to remove ```css .weird-element { content: ^//* some horrible but needed css hack; } ``` but i'm not sure if it's real less.master
parent
5a828bedd1
commit
310fba57cc
|
@ -310,18 +310,11 @@ function parseNestedCSS(node) {
|
|||
? node.raws.selector.raw
|
||||
: node.selector;
|
||||
|
||||
if (selector.trim().endsWith(":")) {
|
||||
try {
|
||||
node.selector = parseSelector(selector);
|
||||
} catch (e) {
|
||||
// Fail silently. It's better to print it as is than to try and parse it
|
||||
node.selector = selector;
|
||||
} else {
|
||||
try {
|
||||
node.selector = parseSelector(selector);
|
||||
} catch (e) {
|
||||
throw createError(
|
||||
"(postcss-selector-parser) " + e.toString(),
|
||||
node.source.start.line,
|
||||
node.source.start.column - 1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (node.type && typeof node.value === "string") {
|
||||
|
@ -361,7 +354,7 @@ function parseWithPostCSSParser(parser, text) {
|
|||
|
||||
function parseWithPostCSS(text) {
|
||||
const r = require;
|
||||
const isLikelySCSS = text.match(/(\w\s*: [^}:]+|#){/);
|
||||
const isLikelySCSS = !!text.match(/(\w\s*: [^}:]+|#){/);
|
||||
try {
|
||||
return parseWithPostCSSParser(
|
||||
r(isLikelySCSS ? "postcss-scss" : "postcss-less"),
|
||||
|
|
|
@ -2545,6 +2545,7 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
case "css-rule": {
|
||||
return concat([
|
||||
path.call(print, "selector"),
|
||||
n.important ? " !important" : "",
|
||||
n.nodes
|
||||
? concat([
|
||||
" {",
|
||||
|
@ -2597,7 +2598,14 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
]);
|
||||
}
|
||||
case "css-import": {
|
||||
return concat(["@", n.name, " ", n.importPath, ";"]);
|
||||
return concat([
|
||||
"@",
|
||||
n.name,
|
||||
" ",
|
||||
n.directives ? concat([n.directives, " "]) : "",
|
||||
n.importPath,
|
||||
";"
|
||||
]);
|
||||
}
|
||||
// postcss-media-query-parser
|
||||
case "media-query-list": {
|
||||
|
@ -2675,7 +2683,7 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
return concat([
|
||||
n.value,
|
||||
n.nodes && n.nodes.length > 0
|
||||
? concat(["(", concat(path.map(print, "nodes")), ")"])
|
||||
? concat(["(", join(", ", path.map(print, "nodes")), ")"])
|
||||
: ""
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`directives.css 1`] = `
|
||||
@import (multiple) "foo.less";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@import (multiple) "foo.less";
|
||||
|
||||
`;
|
|
@ -0,0 +1 @@
|
|||
@import (multiple) "foo.less";
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "postcss" });
|
|
@ -1,8 +1,20 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`important.css 1`] = `
|
||||
max-height: none !important;
|
||||
div {
|
||||
max-height: none !important;
|
||||
}
|
||||
|
||||
.important {
|
||||
.foo() !important;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
max-height: none !important;
|
||||
div {
|
||||
max-height: none !important;
|
||||
}
|
||||
|
||||
.important {
|
||||
.foo() !important;
|
||||
}
|
||||
|
||||
`;
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
max-height: none !important;
|
||||
div {
|
||||
max-height: none !important;
|
||||
}
|
||||
|
||||
.important {
|
||||
.foo() !important;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,9 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`call.css 1`] = `
|
||||
.e:extend(.f, .g) {}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.e:extend(.f, .g) {
|
||||
}
|
||||
|
||||
`;
|
|
@ -0,0 +1 @@
|
|||
.e:extend(.f, .g) {}
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "postcss" });
|
Loading…
Reference in New Issue