Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 &&
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';