storybookjs/storybook
Wrapping `:where` ignored when substituting pseudo-class selector with `.pseudo-*-all` class selector
开放
#31,411 创建于 2025年3月17日
addon: pseudo-statesbugcsshelp wantedsev:S3
仓库指标
- 星标
- (89,909 个星标)
- PR 合并指标
- (平均合并 7天 22小时) (30 天内合并 184 个 PR)
描述
Using storybook 8.3.5 / storybook-addon-pseudo-states 4.0.2 (also an issue in 3.1.1).
Problem
Our typography system has this CSS (only relevant parts shown):
.textLink:where(:focus-visible) { /* specificity 0-1-0 -- tie */
outline: 1px solid var(--my-focus-ring-color);
text-decoration: none;
}
.textLink { /* specificity 0-1-0 -- tie -- but winner due to source order */
text-decoration: underline;
}
The add-on turns it into:
.textLink:where(:focus-visible), /* specificity 0-1-0 */
.textLink:where(.pseudo-focus-visible), /* specificity 0-1-0 */
.pseudo-focus-visible-all .textLink:where(*) { /* BUG 🐞 specificity 0-2-0 -- winner due to higher specificity */
outline: 1px solid var(--my-focus-ring-color);
text-decoration: none;
}
.textLink {
text-decoration: underline; /* specificity 0-1-0 */
}
Which changes the styles, but shouldn't.
Rather, it should output:
.textLink:where(:focus-visible), /* specificity 0-1-0 -- tie */
.textLink:where(.pseudo-focus-visible), /* specificity 0-1-0 -- tie */
:where(.pseudo-focus-visible-all) .textLink { /* FIX 🛠️ specificity 0-1-0 -- tie */
outline: 1px solid var(--my-focus-ring-color);
text-decoration: none;
}
.textLink {
text-decoration: underline; /* specificity 0-1-0 -- tie -- but winner due to source order */
}
Which doesn't change the resultant style.
Possibly relates to storybookjs/storybook-addon-pseudo-states#125 .