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. Only in Firefox the disabled button will have a yellow background.
customElements.define('my-button', class extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({mode: 'open'});
shadowRoot.innerHTML = `
<button disabled part="button">Button in Shadow DOM</button>
`;
}
});
my-button::part(button) {
color: gray;
}
my-button::part(button):disabled {
background-color: yellow;
}
<my-button></my-button>
Is this a Chrome-bug or intended behavior?