Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Shadow Parts Selector ::part() does not work in combination with :disabled pseudo-class in Chrome #918

Closed
Dev89787 opened this issue Mar 31, 2021 · 4 comments

Comments

@Dev89787
Copy link

In Chrome, the pseudo-element selector ::part() and additional :disabled pseudo-class does not work properly. This works in Firefox perfectly.

Here is a corresponding code snippet: https://stackoverflow.com/questions/66867011/css-shadow-parts-selector-part-does-not-work-in-combination-with-disabled-p

Only in Firefox the disabled button will have a yellow background.

Is this a Chrome-bug or intended behavior?

@claviska
Copy link

claviska commented Apr 5, 2021

This looks like a Chrome bug to me. From the spec:

The ::part() pseudo-element can also take additional pseudo-elements after it, such as x-button::part(label)::before, but never match additional ::part()s.

I can confirm this works in Firefox and Safari. Fiddle for reference: https://jsfiddle.net/7Lpqw2um/

Looks like there's already an open issue on the Chromium bug tracker: https://bugs.chromium.org/p/chromium/issues/detail?id=953648

@justinfagnani
Copy link
Contributor

Since this is a Chrome bug, the issue should be closed here.

@Danny-Engelman
Copy link

Danny-Engelman commented Jul 27, 2024

Documenting this here because most searches end up here.

There is more to this. :disabled also breaks grouped CSS in Chromium, and same goes for :checked

Have added this to the Chromium bug report: https://issues.chromium.org/issues/40623497

<button-hover>
  <template shadowrootmode="open">
    <button part="button_hover">:hover</button>
  </template>
</button-hover>
<style>
  button-hover::part(button_hover):hover {
    outline: 5px dashed green;
  }
  button-hover::part(button_hover):disabled,
  button-hover::part(button_hover):hover {
    background: lightgreen; /* not applied in Chromium, works fine in FireFox */
  }
</style>

@Westbrook
Copy link
Collaborator

FYI: I've submitted web-platform-tests/wpt#47440 to hopefully raise the presence of this issue going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants