Skip to content

test: allow declarative shadow dom - #5158

Merged
straker merged 5 commits into
developfrom
declaritive-shadow
Jun 15, 2026
Merged

test: allow declarative shadow dom#5158
straker merged 5 commits into
developfrom
declaritive-shadow

Conversation

@straker

@straker straker commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This allows queryFixture to now support declarative shadow DOM, replacing the need for queryShadowFixture and createNestedShadowDom. I wanted the detection to be conditional so we didn't need to do the expensive calls of setHTMLUnsafe and querying for every shadow on every test. So the code only does the expensive operations when it detects a declarative shadow DOM. Alternatively if we don't like the regex we could just have the options.shadow be passed into the queryFixture, but that would be a bit odd when the 2nd param is the query, but would be fine for the few times we actually use the functions: queryFixture('<div>', '#target', { shadow: true });

@straker
straker requested a review from a team as a code owner June 10, 2026 18:02
Comment thread test/testutils.js
fixture.innerHTML = content;
if (options.shadow) {
// allow declarative shadow DOM which requires using setUnsafeHTML to parse
fixture.setHTMLUnsafe(content);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. I didn't know you could do that!

@WilcoFiers WilcoFiers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checkSetup thing is missing. I think it'd be nice to convert at least a couple tests to use this just to demonstrate it works. I had to do that locally now to learn that.

Comment thread test/testutils.js Outdated
@straker
straker merged commit 24cef87 into develop Jun 15, 2026
23 checks passed
@straker
straker deleted the declaritive-shadow branch June 15, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants