mirror of https://github.com/vuejs/core.git
fix(compiler-sfc): :is() and :where() in compound selectors (#10522)
Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com> Closes #10511
This commit is contained in:
parent
caeb8a6881
commit
660cadc7aa
|
|
@ -161,6 +161,45 @@ describe('SFC scoped CSS', () => {
|
||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #10511
|
||||||
|
test(':is() and :where() in compound selectors', () => {
|
||||||
|
expect(
|
||||||
|
compileScoped(`.div { color: red; } .div:where(:hover) { color: blue; }`),
|
||||||
|
).toMatchInlineSnapshot(`
|
||||||
|
".div[data-v-test] { color: red;
|
||||||
|
}
|
||||||
|
.div[data-v-test]:where(:hover) { color: blue;
|
||||||
|
}"`)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
compileScoped(`.div { color: red; } .div:is(:hover) { color: blue; }`),
|
||||||
|
).toMatchInlineSnapshot(`
|
||||||
|
".div[data-v-test] { color: red;
|
||||||
|
}
|
||||||
|
.div[data-v-test]:is(:hover) { color: blue;
|
||||||
|
}"`)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
compileScoped(
|
||||||
|
`.div { color: red; } .div:where(.foo:hover) { color: blue; }`,
|
||||||
|
),
|
||||||
|
).toMatchInlineSnapshot(`
|
||||||
|
".div[data-v-test] { color: red;
|
||||||
|
}
|
||||||
|
.div[data-v-test]:where(.foo:hover) { color: blue;
|
||||||
|
}"`)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
compileScoped(
|
||||||
|
`.div { color: red; } .div:is(.foo:hover) { color: blue; }`,
|
||||||
|
),
|
||||||
|
).toMatchInlineSnapshot(`
|
||||||
|
".div[data-v-test] { color: red;
|
||||||
|
}
|
||||||
|
.div[data-v-test]:is(.foo:hover) { color: blue;
|
||||||
|
}"`)
|
||||||
|
})
|
||||||
|
|
||||||
test('media query', () => {
|
test('media query', () => {
|
||||||
expect(compileScoped(`@media print { .foo { color: red }}`))
|
expect(compileScoped(`@media print { .foo { color: red }}`))
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,9 @@ function rewriteSelector(
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(n.type !== 'pseudo' && n.type !== 'combinator') ||
|
(n.type !== 'pseudo' && n.type !== 'combinator') ||
|
||||||
(n.type === 'pseudo' && (n.value === ':is' || n.value === ':where'))
|
(n.type === 'pseudo' &&
|
||||||
|
(n.value === ':is' || n.value === ':where') &&
|
||||||
|
!node)
|
||||||
) {
|
) {
|
||||||
node = n
|
node = n
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue