How to use the postcss-selector-parser.isAttribute 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 salesforce / lwc / packages / lwc-style-compiler / src / selector-scoping / validate.ts View on Github external
root.walk(node => {
        if (isAttribute(node)) {
            const { attribute: attributeName, sourceIndex } = node;

            // Let's check if the attribute name is either a Global HTML attribute, an ARIA attribute
            // or a data-* attribute since those are available on all the elements.
            if (isGlobalAttribute(attributeName) || isAriaAttribute(attributeName) || isDataAttribute(attributeName)) {
                return;
            }

            // If the attribute name is not a globally available attribute, the attribute selector is required
            // to be associated with a tag selector, so we can validate its usage. Let's walk the compound selector
            // backward to find the associated tag selector.
            let tagSelector: Tag | undefined = undefined;
            let runner = node.prev();

            while (
                tagSelector === undefined &&
github lttb / reshadow / packages / postcss / transform.js View on Github external
const addMod = node => {
        let {attribute, value = ''} = node;

        let prev = node.prev();

        while (
            prev &&
            !(parser.isTag(prev) || parser.isIdentifier(prev)) &&
            !parser.isCombinator(prev)
        ) {
            const curr = prev;
            prev = curr.prev();

            if (parser.isPseudo(curr)) {
                continue;
            } else if (!parser.isAttribute(curr)) {
                continue;
            }
        }

        const tag = (prev && prev.value) || '__common__';

        value = value.replace(/^['"]/, '').replace(/['"]$/, '');

        let name;
        let type;

        const elem = addElem(tag);

        if (node.namespace) {
            name = `${scope}--${attribute}`;
            type = 'mods';