fix style scoping with > * (#5400)

pull/5402/head
Tan Li Hau 4 years ago committed by GitHub
parent 04498769b5
commit 7900e3eafa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,9 @@
# Svelte changelog
## Unreleased
* Fix scoping of styles involving child selector and `*` ([#5370](https://github.com/sveltejs/svelte/issues/5370))
## 3.25.0
* Use `null` rather than `undefined` for coerced bound value of `<input type="number">` ([#1701](https://github.com/sveltejs/svelte/issues/1701))

@ -152,7 +152,7 @@ function apply_selector(blocks: Block[], node: Element, stack: Element[], to_enc
if (!block) return false;
if (!node) {
return blocks.every(block => block.global);
return block.global && blocks.every(block => block.global);
}
switch (block_might_apply_to_node(block, node)) {
@ -208,7 +208,7 @@ function apply_selector(blocks: Block[], node: Element, stack: Element[], to_enc
return true;
}
function block_might_apply_to_node(block, node): BlockAppliesToNode {
function block_might_apply_to_node(block: Block, node: Element): BlockAppliesToNode {
let i = block.selectors.length;
while (i--) {

@ -0,0 +1,45 @@
export default {
warnings: [
{
code: "css-unused-selector",
message: 'Unused CSS selector "article > *"',
frame: `
1: <style>
2: article > * {
^
3: font-size: 36px;
4: }`,
pos: 10,
start: { character: 10, column: 1, line: 2 },
end: { character: 21, column: 12, line: 2 }
},
{
code: "css-unused-selector",
message: 'Unused CSS selector "article *"',
frame: `
4: }
5:
6: article * {
^
7: font-size: 36px;
8: }`,
pos: 49,
start: { character: 49, column: 1, line: 6 },
end: { character: 58, column: 10, line: 6 }
},
{
code: "css-unused-selector",
message: 'Unused CSS selector ".article > *"',
frame: `
8: }
9:
10: .article > * {
^
11: font-size: 48px;
12: }`,
pos: 86,
start: { character: 86, column: 1, line: 10 },
end: { character: 98, column: 13, line: 10 }
}
]
};

@ -0,0 +1 @@
div.svelte-xyz>.svelte-xyz{color:orange}

@ -0,0 +1,23 @@
<style>
article > * {
font-size: 36px;
}
article * {
font-size: 36px;
}
.article > * {
font-size: 48px;
}
div > * {
color: orange;
}
</style>
<div>
<p>
Svelte REPLs are svelte.
</p>
</div>
Loading…
Cancel
Save