diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index 0e75d318..41cc753a 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -309,7 +309,12 @@ function genericPrint(path, options, print) { return adjustStrings(node.value, options); } case "selector-tag": { - return adjustNumbers(node.value); + return concat([ + node.namespace + ? concat([node.namespace === true ? "" : node.namespace.trim(), "|"]) + : "", + adjustNumbers(node.value) + ]); } case "selector-id": { return concat(["#", node.value]); @@ -358,7 +363,12 @@ function genericPrint(path, options, print) { return concat([leading, value]); } case "selector-universal": { - return node.value; + return concat([ + node.namespace + ? concat([node.namespace === true ? "" : node.namespace.trim(), "|"]) + : "", + adjustNumbers(node.value) + ]); } case "selector-selector": { return group(indent(concat(path.map(print, "nodes")))); diff --git a/tests/css_selector_list/__snapshots__/jsfmt.spec.js.snap b/tests/css_selector_list/__snapshots__/jsfmt.spec.js.snap index 024669b0..01df2c59 100644 --- a/tests/css_selector_list/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css_selector_list/__snapshots__/jsfmt.spec.js.snap @@ -295,6 +295,23 @@ exports[`selectors.css 1`] = ` >>> .child-one {} >>> .child-two {} } + +/* This matches all XHTML elements, as XHTML is the default unprefixed namespace */ +a {} + +/* This matches all SVG elements */ +svg|a {} + +/* This matches both XHTML and SVG elements */ +*|a {} + +|B {} + +ns|* {} + +*|* {} + +|* {} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .a, .b, @@ -660,4 +677,28 @@ exports[`selectors.css 1`] = ` } } +/* This matches all XHTML elements, as XHTML is the default unprefixed namespace */ +a { +} + +/* This matches all SVG elements */ +svg|a { +} + +/* This matches both XHTML and SVG elements */ +*|a { +} + +|B { +} + +ns|* { +} + +*|* { +} + +|* { +} + `; diff --git a/tests/css_selector_list/selectors.css b/tests/css_selector_list/selectors.css index 9dfdf1b9..26eedf45 100644 --- a/tests/css_selector_list/selectors.css +++ b/tests/css_selector_list/selectors.css @@ -292,3 +292,20 @@ >>> .child-one {} >>> .child-two {} } + +/* This matches all XHTML elements, as XHTML is the default unprefixed namespace */ +a {} + +/* This matches all SVG elements */ +svg|a {} + +/* This matches both XHTML and SVG elements */ +*|a {} + +|B {} + +ns|* {} + +*|* {} + +|* {}