Skip to content

Commit e8094df

Browse files
authored
fix remove of lone :host selectors (#5984)
1 parent 160a4ec commit e8094df

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Svelte changelog
22

3+
## Unreleased
4+
5+
* Fix removal of lone `:host` selectors ([#5982](https://github.com/sveltejs/svelte/issues/5982))
6+
37
## 3.32.2
48

59
* Fix unnecessary additional invalidation with `<Component bind:prop={obj.foo}/>` ([#3075](https://github.com/sveltejs/svelte/issues/3075), [#4447](https://github.com/sveltejs/svelte/issues/4447), [#5555](https://github.com/sveltejs/svelte/issues/5555))

src/compiler/compile/css/Selector.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ export default class Selector {
4444
}
4545

4646
this.local_blocks = this.blocks.slice(0, i);
47-
this.used = this.local_blocks.length === 0;
47+
48+
const host_only = this.blocks.length === 1 && this.blocks[0].host;
49+
50+
this.used = this.local_blocks.length === 0 || host_only;
4851
}
4952

5053
apply(node: Element) {

test/css/samples/host/expected.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/css/samples/host/input.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
:host > span {
1919
color: red;
2020
}
21+
22+
:host {
23+
color: red;
24+
}
2125
</style>
2226

2327
<h1>Hello!</h1>

0 commit comments

Comments
 (0)