Skip to content

Commit

Permalink
fix remove of lone :host selectors (sveltejs#5984)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau authored Feb 11, 2021
1 parent 160a4ec commit e8094df
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Svelte changelog

## Unreleased

* Fix removal of lone `:host` selectors ([#5982](https://github.com/sveltejs/svelte/issues/5982))

## 3.32.2

* 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))
Expand Down
5 changes: 4 additions & 1 deletion src/compiler/compile/css/Selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export default class Selector {
}

this.local_blocks = this.blocks.slice(0, i);
this.used = this.local_blocks.length === 0;

const host_only = this.blocks.length === 1 && this.blocks[0].host;

this.used = this.local_blocks.length === 0 || host_only;
}

apply(node: Element) {
Expand Down
2 changes: 1 addition & 1 deletion test/css/samples/host/expected.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions test/css/samples/host/input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
:host > span {
color: red;
}
:host {
color: red;
}
</style>

<h1>Hello!</h1>
Expand Down

0 comments on commit e8094df

Please sign in to comment.