How to use the postcss-selector-parser.COMBINATOR 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 / BlockParser.ts View on Github external
classStates.add(stateStr);
        } else {
          thisElementIsRoot = true;
          thisType = BlockTypes.state;
          states.add(stateStr);
        }
      } else if (s.type === selectorParser.CLASS) {
        if (thisElementIsRoot && lastCombinator !== null && siblingCombinators.has(lastCombinator)) {
          throw new errors.InvalidBlockSyntax(
            `A class is never a sibling of a state: ${rule.selector}`,
            selectorSourceLocation(sourceFile, rule, selector.nodes[0]));
        }
        thisElementIsRoot = false;
        thisType = BlockTypes.class;
        classes.add(s.value);
      } else if (s.type === selectorParser.COMBINATOR) {
        thisType = null;
        combinators.add(s.value);
        lastCombinator = s.value;
        if (!siblingCombinators.has(s.value)) {
          lastElementIsRoot = thisElementIsRoot;
          thisElementIsRoot = false;
        }
      }
      if (thisType && lastType && lastType !== thisType) {
        if ((lastType === BlockTypes.block && thisType === BlockTypes.state) ||
            (thisType === BlockTypes.block && lastType === BlockTypes.state)) {
          throw new errors.InvalidBlockSyntax(
            `It's redundant to specify state with the block root: ${rule.selector}`,
            selectorSourceLocation(sourceFile, rule, selector.nodes[0]));
        }
        if (lastType === BlockTypes.state && thisType === BlockTypes.class) {
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) {