make pseudo class name meta always an array

master
Brad Cornes 2020-06-12 11:26:17 +01:00
parent cc587adf35
commit d5b5176756
3 changed files with 6 additions and 10 deletions

View File

@ -36,7 +36,7 @@ function getClassNamesFromSelector(selector) {
className: node.value.trim(),
scope: createSelectorFromNodes(scope),
__rule: j === subSelectors[i].nodes.length - 1,
__pseudo: pseudo.length === 0 ? null : pseudo.map(String),
__pseudo: pseudo.map(String),
})
}
scope.push(node, ...pseudo)
@ -115,9 +115,7 @@ async function process(groups) {
dsetEach(tree, [...baseKeys, ...index], decls)
}
if (classNames[i].__pseudo) {
dset(tree, [...baseKeys, '__pseudo'], classNames[i].__pseudo)
}
dset(tree, [...baseKeys, ...index, '__pseudo'], classNames[i].__pseudo)
dset(tree, [...baseKeys, ...index, '__scope'], classNames[i].scope)
dset(
tree,
@ -126,9 +124,7 @@ async function process(groups) {
)
// common context
if (classNames[i].__pseudo) {
context.push(...classNames[i].__pseudo)
}
context.push(...classNames[i].__pseudo)
for (let i = 0; i < contextKeys.length; i++) {
if (typeof commonContext[contextKeys[i]] === 'undefined') {

View File

@ -200,8 +200,8 @@ function provideAtApplyCompletions(
return (
!Array.isArray(info) &&
info.__source === 'utilities' &&
(info.__context || []).length === 0 &&
(info.__pseudo || []).length === 0
info.__context.length === 0 &&
info.__pseudo.length === 0
)
}
)

View File

@ -54,7 +54,7 @@ export function stringifyCss(className: string, obj: any): string {
}
function augmentClassName(className: string, obj: any): string {
const pseudo = obj.__pseudo ? obj.__pseudo.join('') : ''
const pseudo = obj.__pseudo.join('')
const scope = obj.__scope ? `${obj.__scope} ` : ''
return `${scope}.${escapeClassName(className)}${pseudo}`
}