How to use the postcss-selector-parser.selector 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 tivac / modular-css / packages / processor / plugins / externals.js View on Github external
const process = (rule, pseudo) => {
        const params = pseudo.nodes.toString();
        const { source, ref } = parser.parse(params);
        const { name } = ref;
        const file = files[resolve(from, source)];
        
        if(!file.exports[name]) {
            throw rule.error(`Invalid external reference: ${name}`, { word : name });
        }
        
        // This was a... poor naming choice
        const s = selector.selector();
        
        file.exports[name].forEach((value) =>
            s.append(selector.className({ value }))
        );
        
        const root = selector.root();
        
        root.append(s);

        pseudo.replaceWith(root);
    };
github tivac / modular-css / packages / processor / plugins / scoping.js View on Github external
pseudos.forEach((node) => {
            // Replace the :global(...) with its contents
            node.replaceWith(processor.selector({
                nodes  : node.nodes,
                source : node.source,
            }));

            node.walk((child) => {
                const key = rename(current, child);

                if(!key) {
                    return;
                }

                // Don't allow local/global overlap (but globals can overlap each other nbd)
                if(key in lookup && !globals[key]) {
                    throw current.error(reuse, { word : key });
                }
github Semigradsky / postcss-attribute-case-insensitive / src / index.js View on Github external
function createNewSelectors(selector) {
	let newSelectors = [parser.selector()];

	selector.walk(node => {
		if (!nodeIsInsensitiveAttribute(node)) {
			newSelectors.forEach(newSelector => {
				newSelector.append(node.clone());
			});
			return;
		}

		const sensitiveAttributes = createSensitiveAtributes(node);
		const newSelectorsWithSensitiveAttributes = [];

		sensitiveAttributes.forEach(newNode => {
			newSelectors.forEach(newSelector => {
				const newSelectorWithNewNode = newSelector.clone();
				newSelectorWithNewNode.append(newNode);