How to use the postcss-selector-parser.PSEUDO function in postcss-selector-parser

To help you get started, we’ve selected a few postcss-selector-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sinnerschrader / schlump / src / css-matcher.js View on Github external
isTypeMatching(node) {
		switch (node.type) {
			case selectorParser.TAG:
				return this.findMatchingSibling(node, node => {
					return node.value === this.currentNode.tag;
				});
			case selectorParser.COMBINATOR:
				return this.isCombinatorMatching(node);
			case selectorParser.CLASS:
				return this.findMatchingSibling(node, node => (this.currentNode.class || '').split(' ').includes(node.value));
			case selectorParser.ATTRIBUTE:
				return this.findMatchingSibling(node, node => this.isAttributeMatching(node));
			case selectorParser.PSEUDO:
				if (node.value === ':root') {
					this.toParent();
					this.updateCurrentSiblings();
					return Object.keys(this.currentNode).length === 0;
				}
				return true;
			default:
				return false;
		}
	}
github linkedin / css-blocks / src / css-blocks.ts View on Github external
selector.each((s) => {
    if (s.type === selectorParser.PSEUDO && s.value === ":state") {
      let info = stateParser(rule, s);
      if (info.group) {
        states.add(`${info.group} ${info.name}`);
      } else {
        states.add(info.name);
      }
    } else if (s.type === selectorParser.COMBINATOR) {
      combinators.add(s.value);
    }
    return true;
  });
  if (combinators.size > 0 && states.size > 1) {
github sinnerschrader / schlump / src / css.js View on Github external
function isOnlyPseudoRootSelector(selector) {
	return selector.nodes.length === 1 && selector.first.type === selectorParser.PSEUDO &&
		selector.first.value === ':root';
}