Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.values(defMeta.mappedSymbols).some(sym => {
const symbolStates = sym._kind === 'class' && sym[valueMapping.states];
// states
return (
sym._kind === 'class' &&
symbolStates &&
Object.keys(symbolStates).some(k => {
if (k === word && !!pos) {
const postcsspos = new ProviderPosition(pos.line + 1, pos.character);
const pfp = pathFromPosition(callingMeta.rawAst, postcsspos, [], true);
const selec = (pfp[pfp.length - 1] as postcss.Rule).selector;
// If called from -st-state, i.e. inside node, pos is not in selector.
// Use 1 and not 0 for selector that starts with'.'
const char = isInNode(postcsspos, pfp[pfp.length - 1]) ? 1 : pos.character;
const parsel = parseSelector(selec, char);
const t = parsel.target;
const arr = Array.isArray(t.focusChunk)
? (t.focusChunk as SelectorQuery[])[t.index].text
const newStates = lastNode.resolved.reduce((acc, cur) => {
let relPath = path.relative(path.dirname(meta.source), cur.meta.source);
if (!relPath.startsWith('.')) {
relPath = './' + relPath;
}
const symbol = cur.symbol;
if (symbol._kind === 'class') {
const symbolStates = symbol[valueMapping.states];
if (symbolStates) {
Object.keys(symbolStates).forEach(k => {
if (
!acc[k] &&
// selectoid is a substring of current state
(k.slice(0, -1).startsWith(lastSelectoid.replace(':', '')) ||
// selectoid is a CSS native pseudo-sclass
nativePseudoClasses.indexOf(lastSelectoid.replace(':', '')) !==
-1 ||
allStates.hasOwnProperty(lastSelectoid.replace(':', ''))) &&
chunkyStates.every(cs => cs !== k)
) {
const symbolStates = symbol[valueMapping.states];
const stateDef = symbolStates && symbolStates[k];
Object.values(meta.mappedSymbols).some(k => {
if (k._kind === 'class') {
const symbolStates = k[valueMapping.states];
if (symbolStates && Object.keys(symbolStates).some(key => key === word)) {
const postcsspos = new ProviderPosition(
position.line + 1,
position.character
);
const pfp = pathFromPosition(callingMeta.rawAst, postcsspos, [], true);
const selec = (pfp[pfp.length - 1] as postcss.Rule).selector;
// If called from -st-state, i.e. inside node, pos is not in selector.
// Use 1 and not 0 for selector that starts with'.'
const char = isInNode(postcsspos, pfp[pfp.length - 1])
? 1
: position.character;
const parsel = parseSelector(selec, char);
const t = parsel.target;
symb.resolved.some(inner => {
if (inner.symbol._kind === 'class') {
const symbolStates = inner.symbol[valueMapping.states];
return (
symbolStates &&
inner.meta.source === defMeta.source &&
Object.keys(symbolStates).indexOf(word) !== -1
);
}
return false;
})
) {
const states = lastNode.resolved.reduce((acc, cur) => {
if (cur.symbol._kind === 'class') {
const symbolStates = cur.symbol[valueMapping.states];
if (symbolStates) {
acc = acc.concat(Object.keys(symbolStates));
}
}
return acc;
}, cssPseudoClasses);
Object.keys(symbolStates).forEach(k => {
const symbolStates = symbol[valueMapping.states];
if (symbolStates && symbolStates[k] !== undefined) {
acc[k] = symbolStates[k];
}
});
}