mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
fix style scoping with > * (#5400)
This commit is contained in:
parent
04498769b5
commit
7900e3eafa
@ -1,5 +1,9 @@
|
|||||||
# Svelte changelog
|
# Svelte changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
* Fix scoping of styles involving child selector and `*` ([#5370](https://github.com/sveltejs/svelte/issues/5370))
|
||||||
|
|
||||||
## 3.25.0
|
## 3.25.0
|
||||||
|
|
||||||
* Use `null` rather than `undefined` for coerced bound value of `<input type="number">` ([#1701](https://github.com/sveltejs/svelte/issues/1701))
|
* 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 (!block) return false;
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return blocks.every(block => block.global);
|
return block.global && blocks.every(block => block.global);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (block_might_apply_to_node(block, node)) {
|
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;
|
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;
|
let i = block.selectors.length;
|
||||||
|
|
||||||
while (i--) {
|
while (i--) {
|
||||||
|
45
test/css/samples/unused-selector-child-combinator/_config.js
Normal file
45
test/css/samples/unused-selector-child-combinator/_config.js
Normal file
@ -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…
Reference in New Issue
Block a user