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 flaviuse / mern-authentication / client / node_modules / postcss-modules-local-by-default / index.js View on Github external
// because this node has spacing that is lost when we remove it
          // we make up for it by adding an extra combinator in since adding
          // spacing on the parent selector doesn't work
          return addBackSpacing
            ? selectorParser.combinator({ value: ' ' })
            : null;
        }
        break;
      }
      case 'id':
      case 'class': {
        if (!context.global) {
          const innerNode = node.clone();
          innerNode.spaces = { before: '', after: '' };

          node = selectorParser.pseudo({
            value: ':local',
            nodes: [innerNode],
            spaces: node.spaces,
          });

          context.hasLocals = true;
        }

        break;
      }
    }

    context.lastWasSpacing = false;
    context.ignoreNextSpacing = false;
    context.enforceNoSpacing = false;
github linkedin / css-blocks / packages / @css-blocks / bem-to-blocks / src / index.ts View on Github external
// 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",
              });
              if (selector.parent) {
                selector.parent.insertBefore(selector, newScopeNode);
              }
              stripSelector = true;
            }

            if (blockClassName.state) {
              let newAttrNode = parser.attribute({
                attribute: blockClassName.state,
                quoteMark: null,
                operator: blockClassName.subState ? "=" : undefined,
                value: blockClassName.subState,
                raws: {},
              });
github benface / tailwindcss-interaction-variants / index.js View on Github external
sel.walkClasses(classNode => {
              classNode.value = `hocus${separator}${classNode.value}`;
              classNode.parent.insertAfter(classNode, selectorParser.pseudo({ value: `:${i === 0 ? 'hover' : 'focus'}` }));
            });
          });
github makuga01 / dnsFookup / FE / node_modules / postcss-modules-local-by-default / index.js View on Github external
if (!node.value) {
          throw new Error('Invalid class or id selector syntax');
        }

        if (context.global) {
          break;
        }

        const isImportedValue = localAliasMap.has(node.value);
        const isImportedWithExplicitScope = isImportedValue && context.explicit;

        if (!isImportedValue || isImportedWithExplicitScope) {
          const innerNode = node.clone();
          innerNode.spaces = { before: '', after: '' };

          node = selectorParser.pseudo({
            value: ':local',
            nodes: [innerNode],
            spaces: node.spaces,
          });

          context.hasLocals = true;
        }

        break;
      }
    }

    context.lastWasSpacing = false;
    context.ignoreNextSpacing = false;
    context.enforceNoSpacing = false;
github m18ru / postcss-text-remove-gap / index.js View on Github external
var transform = function ( selectors )
	{
		var selectorIndex = -1;
		var selector;
		
		while ( selector = selectors.nodes[++selectorIndex] )
		{
			selector.append(
				selectorParser.pseudo( {value: pseudo} )
			);
		}
	};