Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld authored Mar 11, 2024
2 parents 8845fb1 + c211e60 commit d5f74eb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# v2.2.1 (Tue Mar 05 2024)

#### 🐛 Bug Fix

- Avoid generating invalid selector with `:has` [#105](https://github.com/chromaui/storybook-addon-pseudo-states/pull/105) ([@m-akinc](https://github.com/m-akinc))

#### Authors: 1

- [@m-akinc](https://github.com/m-akinc)

---

# v2.2.0 (Mon Mar 04 2024)

#### 🚀 Enhancement
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storybook-addon-pseudo-states",
"version": "2.2.0",
"version": "2.2.1",
"description": "CSS pseudo states for Storybook",
"keywords": [
"storybook-addons",
Expand Down
6 changes: 6 additions & 0 deletions src/preview/rewriteStyleSheet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ describe("rewriteStyleSheet", () => {
expect(sheet.cssRules[0].selectorText).toEqual(":not(:hover), :not(.pseudo-hover)")
})

it('supports ":has"', () => {
const sheet = new Sheet(":has(:hover) { color: red }")
rewriteStyleSheet(sheet as any)
expect(sheet.cssRules[0].cssText).toEqual(":has(:hover), :has(.pseudo-hover) { color: red }")
})

it("override correct rules with media query present", () => {
const sheet = new Sheet(
`@media (max-width: 790px) {
Expand Down
2 changes: 1 addition & 1 deletion src/preview/rewriteStyleSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const rewriteRule = ({ cssText, selectorText }: CSSStyleRule, shadowRoot?: Shado
}

return [selector, classSelector, ancestorSelector].filter(
(selector) => selector && !selector.includes(":not()")
(selector) => selector && !selector.includes(":not()") && !selector.includes(":has()")
)
})
.join(", ")
Expand Down

0 comments on commit d5f74eb

Please sign in to comment.