parent
48d9267dd5
commit
2f6d12aaa8
|
@ -220,6 +220,34 @@ function parseValueNodes(nodes) {
|
|||
return rootParenGroup;
|
||||
}
|
||||
|
||||
function flattenGroups(node) {
|
||||
if (
|
||||
node.type === "paren_group" &&
|
||||
!node.open &&
|
||||
!node.close &&
|
||||
node.groups.length === 1
|
||||
) {
|
||||
return flattenGroups(node.groups[0]);
|
||||
}
|
||||
|
||||
if (
|
||||
node.type === "comma_group" &&
|
||||
node.groups.length === 1
|
||||
) {
|
||||
return flattenGroups(node.groups[0]);
|
||||
}
|
||||
|
||||
if (node.type === "paren_group" || node.type === "comma_group") {
|
||||
return Object.assign(
|
||||
{},
|
||||
node,
|
||||
{groups: node.groups.map(flattenGroups)}
|
||||
);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function addTypePrefix(node, prefix) {
|
||||
if (node && typeof node === "object") {
|
||||
delete node.parent;
|
||||
|
@ -254,7 +282,7 @@ function parseNestedValue(node) {
|
|||
for (const key in node) {
|
||||
parseNestedValue(node[key]);
|
||||
if (key === "nodes") {
|
||||
node.group = parseValueNodes(node[key]);
|
||||
node.group = flattenGroups(parseValueNodes(node[key]));;
|
||||
delete node[key];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2635,7 +2635,23 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
}
|
||||
case "value-paren_group": {
|
||||
if (!n.open) {
|
||||
return join(concat([",", line]), path.map(print, "groups"));
|
||||
return group(join(concat([",", line]), path.map(print, "groups")));
|
||||
}
|
||||
|
||||
const parent = path.getParentNode();
|
||||
if (
|
||||
parent &&
|
||||
parent.type === "value-func" &&
|
||||
parent.value === "url" &&
|
||||
n.groups.length === 1 &&
|
||||
n.groups[0].type === "value-string"
|
||||
) {
|
||||
return concat([
|
||||
n.open ? path.call(print, "open") : "",
|
||||
join(", ", path.map(print, "groups")),
|
||||
n.close ? path.call(print, "close") : ""
|
||||
])
|
||||
|
||||
}
|
||||
|
||||
return group(
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`inline_url.js 1`] = `
|
||||
.breadItem {
|
||||
background-image: url('/images/product/simple_product_manager/breadcrumb/chevron_right.png');
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.breadItem {
|
||||
background-image: url('/images/product/simple_product_manager/breadcrumb/chevron_right.png');
|
||||
}
|
||||
|
||||
`;
|
|
@ -0,0 +1,3 @@
|
|||
.breadItem {
|
||||
background-image: url('/images/product/simple_product_manager/breadcrumb/chevron_right.png');
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "postcss" });
|
Loading…
Reference in New Issue