Skip to content

Commit

Permalink
fix: support attribute selector inside :global() (#11135)
Browse files Browse the repository at this point in the history
* fix: support attribute selector inside :global()

* Update Selector.js
  • Loading branch information
tanhauhau authored Apr 17, 2024
1 parent ad00cad commit a510c6a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tricky-onions-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

support attribute selector inside :global()
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/compile/css/Selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default class Selector {
index !== 0 &&
selector.children &&
selector.children.length > 0 &&
!/[.:#\s]/.test(selector.children[0].value[0])
!/[.:#[\s]/.test(selector.children[0].value[0])
) {
component.error(selector, compiler_errors.css_invalid_global_selector_position);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.anim-checkbox.svelte-xyz[data-state='checked']{background-color:red}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<style>
.anim-checkbox:global([data-state='checked']) {
background-color: red;
}
</style>
<div class="anim-checkbox"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<style>
.anim-checkbox:global([data-state='checked']) {
background-color: red;
}
</style>
<div class="anim-checkbox"></div>

0 comments on commit a510c6a

Please sign in to comment.