Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (n.type === 'pseudo') {
// deep: inject [id] attribute at the node before the ::v-deep
// combinator.
if (n.value === '::v-deep') {
if (n.nodes.length) {
// .foo ::v-deep(.bar) -> .foo[xxxxxxx] .bar
// replace the current node with ::v-deep's inner selector
selector.insertAfter(n, n.nodes[0])
// insert a space combinator before if it doesn't already have one
const prev = selector.at(selector.index(n) - 1)
if (!prev || !isSpaceCombinator(prev)) {
selector.insertAfter(
n,
selectorParser.combinator({
value: ' '
})
)
}
selector.removeChild(n)
} else {
// DEPRECATED usage
// .foo ::v-deep .bar -> .foo[xxxxxxx] .bar
console.warn(
`[@vue/compiler-sfc] ::v-deep usage as a combinator has ` +
`been deprecated. Use ::v-deep() instead.`
)
const prev = selector.at(selector.index(n) - 1)
if (prev && isSpaceCombinator(prev)) {
selector.removeChild(prev)
}
context.ignoreNextSpacing = context.lastWasSpacing
? node.value
: false;
context.enforceNoSpacing = context.lastWasSpacing
? false
: node.value;
context.global = node.value === ':global';
context.explicit = true;
// 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 (!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;
selector.each(n => {
if (isDeepCombinator(n)) {
// Use descendant combinator instead of deep combinator
n.replaceWith(selectorParser.combinator({
value: ' '
}))
}
})
}
context.ignoreNextSpacing = context.lastWasSpacing
? node.value
: false;
context.enforceNoSpacing = context.lastWasSpacing
? false
: node.value;
context.global = node.value === ':global';
context.explicit = true;
// 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,
});
contextSelectors => {
const clone = selector.clone();
if (!hostNode) {
clone.prepend(hostPlaceholder());
}
clone.prepend(selectorParser.combinator({ value: ' ' }));
contextSelectors.each(node => {
trimNodeWhitespaces(node);
clone.prepend(node);
});
return clone;
},
);
child.selectors.forEach(function (j) {
var node = parse(j, child)
var replaced = replace(node, parentNode)
if (!replaced) {
node.prepend(parser.combinator({ value: ' ' }))
node.prepend(parentNode.clone())
}
result.push(node.toString())
})
})
selectors.each((selector: any) => {
let node = null
selector.each((n: any) => {
if (n.type !== 'pseudo') node = n
})
selector.insertAfter(node, selectorParser.attribute({ attribute: value }))
selector.prepend(selectorParser.combinator({ value: CSS_PLACEHOLDER }))
})
}