blob: 8a37e054893a0b71a29bcdd128f2022bc7f8b74b [file] [log] [blame]
/* @flow */
"use strict";
/**
* Check whether a combinator is standard
*
* @param {Node} postcss-selector-parser node (of type combinator)
* @return {boolean} If `true`, the combinator is standard
*/
const _ = require("lodash");
module.exports = function(node /*: Object*/) /*: boolean*/ {
// Ghost descendant combinators around reference combinators like `/deep/`
// postcss-selector-parser parsers references combinators as tag selectors surrounded
// by descendant combinators
if (
(node.prev() &&
node.prev().type === "tag" &&
_.startsWith(node.prev().value, "/") &&
_.endsWith(node.prev().value, "/")) ||
(node.next() &&
node.next().type === "tag" &&
_.startsWith(node.next().value, "/") &&
_.endsWith(node.next().value, "/"))
) {
return false;
}
return true;
};