How to use the postcss-selector-parser.CLASS 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 youzan / zent / packages / zent / plugins / postcss-plugin-version-attribute.js View on Github external
selector.walk(node => {
        const { type } = node;
        if (
          type === parseSelector.CLASS ||
          type === parseSelector.ID ||
          type === parseSelector.ATTRIBUTE ||
          type === parseSelector.TAG
        ) {
          interestedNode = node;
          return false; /* break */
        }
      });
      if (interestedNode) {
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 sinnerschrader / schlump / src / css.js View on Github external
function isClassWithAttributeSelectorNode(selector, i) {
	return selector.nodes[i].type === selectorParser.ATTRIBUTE &&
		(i === 0 || selector.nodes[i - 1].type !== selectorParser.CLASS);
}
function isSimpleClassSelector(selector) {
github linkedin / css-blocks / src / BlockParser.ts View on Github external
}));
                  replacements.push([lastSel, null]);
                }
              } else {
                let state = block.ensureState(stateParser(sourceFile, rule, s));
                if (s.parent === individualSelector) {
                  thisNode = state;
                }
                if (mutate) {
                  replacements.push(this.mutate(state, s, individualSelector, (newClass) => {
                    thisSel = newClass;
                  }));
                }
              }
            }
            else if (s.type === selectorParser.CLASS) {
              let blockClass = block.ensureClass(s.value);
              if (s.parent === individualSelector) {
                thisNode = blockClass;
              }
              if (mutate) {
                replacements.push(this.mutate(blockClass, s, individualSelector, (newClass) => {
                  thisSel = newClass;
                }));
              }
            } else if (s.parent === individualSelector) {
              thisNode = null;
              thisSel = null;
            }

            if (s.parent === individualSelector) {
              lastNode = thisNode;
github sinnerschrader / schlump / src / css.js View on Github external
function isSimpleClassWithPseudoSelector(selector) {
	return selector.nodes.length === 2 && selector.nodes[0].type === selectorParser.CLASS &&
		selector.nodes[1].type === selectorParser.PSEUDO;
}
function isOnlyPseudoRootSelector(selector) {