-
Notifications
You must be signed in to change notification settings - Fork 883
Shadow Root with inline style fails to fetch cssom #4137
Copy link
Copy link
Closed
Labels
ungroomedTicket needs a maintainer to prioritize and labelTicket needs a maintainer to prioritize and label
Description
Product
axe-core
Product Version
4.7.2
Latest Version
- I have tested the issue with the latest version of the product
Issue Description
Expectation
No errors when testing Lit components
Actual
When I have inline style on my shadowroot, it triggers an error

Removing the inline style, it will not trigger an error.

How to Reproduce
Create a simple Lit component
import { LitElement, css, html } from "lit";
import { customElement, property } from "lit/decorators.js";
@customElement("primitive-accordion")
export class PrimitiveAccordion extends LitElement {
static styles = css`
:host {
color: blue;
}
`;
@property({ reflect: true })
name: string;
constructor() {
super();
this.name = "World";
}
// Render the UI as a function of component state
render() {
return html`<div>
<h1>Hello, ${this.name}!</h1>
</div>`;
}
}
declare global {
interface HTMLElementTagNameMap {
"primitive-accordion": PrimitiveAccordion;
}
}And run this simple test
import { afterEach, beforeEach, describe, it } from "vitest";
import "../lib/accordion";
import { expect, fixture, html } from "@open-wc/testing";
describe("given a single accordion", async () => {
let root: HTMLDivElement;
beforeEach(() => {
root = document.createElement("div");
document.body.appendChild(root);
});
afterEach(() => {
root?.remove();
});
it("should have no accessibility violations in default state", async () => {
const el = await fixture(
html` <primitive-accordion name="Testing"></primitive-accordion> `
);
console.log(el.shadowRoot?.innerHTML);
await expect(el).to.be.accessible();
});
});Additional context
The error is originated on the function getStylesheetsFromDocumentFragment inside the file preload-cssom.js. The function convertDataToStylesheet will return null on stylesheet.sheet. Checking the value of stylesheet.sheet should fix the issue. I'm creating a PR for that fix right now :)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ungroomedTicket needs a maintainer to prioritize and labelTicket needs a maintainer to prioritize and label
Type
Fields
Give feedbackNo fields configured for issues without a type.