How to use the postcss-selector-parser.isClassName 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 linkedin / css-blocks / packages / @css-blocks / bem-to-blocks / src / index.ts View on Github external
selectors.walk((selector) => {
        // we only need to modify class names. We can ignore everything else,
        // like existing attributes, pseudo selectors, comments, imports,
        // exports, etc
        if (parser.isClassName(selector)) {

          let bemSelector = bemSelectorCache.get(selector.value);
          // get the block class from the bemSelector
          let blockClassName = bemSelector && bemToBlockClassMap.get(bemSelector);

          // if the selector was previously cached
          if (blockClassName) {
            let stripSelector = false;

            if (blockClassName.class) {
              selector.value =  blockClassName.class;
            } else {
              //prepend a :scope node before this and remove this node later
              let newScopeNode = parser.pseudo({
                value: ":scope",
              });
github kristerkari / stylelint-scss / src / rules / selector-no-union-class-name / index.js View on Github external
root.walkRules(/&/, rule => {
      const parentNodes = [];

      const selector = getSelectorFromRule(rule.parent);

      if (selector) {
        parseSelector(selector, result, rule, fullSelector => {
          fullSelector.walk(node => parentNodes.push(node));
        });
      }

      if (parentNodes.length === 0) return;

      const lastParentNode = parentNodes[parentNodes.length - 1];

      if (!isClassName(lastParentNode)) return;

      parseSelector(rule.selector, result, rule, fullSelector => {
        fullSelector.walkNesting(node => {
          const next = node.next();

          if (!next) return;

          if (validNestingTypes.some(isType => isType(next))) return;

          utils.report({
            ruleName,
            result,
            node: rule,
            message: messages.rejected,
            index: node.sourceIndex
          });