Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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;
// 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: {},
});
sel.walkClasses(classNode => {
classNode.value = `hocus${separator}${classNode.value}`;
classNode.parent.insertAfter(classNode, selectorParser.pseudo({ value: `:${i === 0 ? 'hover' : 'focus'}` }));
});
});
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;
var transform = function ( selectors )
{
var selectorIndex = -1;
var selector;
while ( selector = selectors.nodes[++selectorIndex] )
{
selector.append(
selectorParser.pseudo( {value: pseudo} )
);
}
};