Add support for media-url (#1797)
parent
c9159f7862
commit
bf5f9cc05d
|
@ -212,7 +212,7 @@ function requireParser(isSCSS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse(text) {
|
function parse(text) {
|
||||||
const isLikelySCSS = !!text.match(/(\w\s*: [^}:]+|#){/);
|
const isLikelySCSS = !!text.match(/(\w\s*: [^}:]+|#){|\@import url/);
|
||||||
try {
|
try {
|
||||||
return parseWithParser(requireParser(isLikelySCSS), text);
|
return parseWithParser(requireParser(isLikelySCSS), text);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -2604,7 +2604,15 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
}
|
}
|
||||||
// postcss-media-query-parser
|
// postcss-media-query-parser
|
||||||
case "media-query-list": {
|
case "media-query-list": {
|
||||||
return join(", ", path.map(print, "nodes"));
|
const parts = [];
|
||||||
|
path.each(childPath => {
|
||||||
|
const node = childPath.getValue();
|
||||||
|
if (node.type === "media-query" && node.value === "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parts.push(childPath.call(print));
|
||||||
|
}, "nodes");
|
||||||
|
return join(", ", parts);
|
||||||
}
|
}
|
||||||
case "media-query": {
|
case "media-query": {
|
||||||
return join(" ", path.map(print, "nodes"));
|
return join(" ", path.map(print, "nodes"));
|
||||||
|
@ -2630,6 +2638,9 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
case "media-keyword": {
|
case "media-keyword": {
|
||||||
return n.value;
|
return n.value;
|
||||||
}
|
}
|
||||||
|
case "media-url": {
|
||||||
|
return n.value;
|
||||||
|
}
|
||||||
case "media-unknown": {
|
case "media-unknown": {
|
||||||
return n.value;
|
return n.value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,3 +6,12 @@ exports[`directives.css 1`] = `
|
||||||
@import (multiple) "foo.less";
|
@import (multiple) "foo.less";
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`url.css 1`] = `
|
||||||
|
@import url('foo');
|
||||||
|
$dir: 'fonts';
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@import url('foo');
|
||||||
|
$dir: 'fonts';
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
@import url('foo');
|
||||||
|
$dir: 'fonts';
|
Loading…
Reference in New Issue