Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Commit d36d582

Browse files
committed
Fix selector scoping for Storybook iframe-prefixed selectors
Strip the iframe-piercing prefix (e.g. #storybook-preview-iframe >>> iframe>) from violation selectors before calling querySelector. This is a no-op for plain selectors outside Storybook.
1 parent d47e61f commit d36d582

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@accesslint/vitest",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "Accessibility assertions for Vitest — toBeAccessible() matcher powered by AccessLint",
55
"license": "MIT",
66
"publishConfig": {

src/matchers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function scopeViolationsToElement(
1919
): Violation[] {
2020
return violations.filter((v) => {
2121
try {
22-
const el = root.ownerDocument.querySelector(v.selector);
22+
const local = v.selector.replace(/^.*>>>\s*iframe>\s*/, "");
23+
const el = root.ownerDocument.querySelector(local);
2324
return el && root.contains(el);
2425
} catch {
2526
return false;

0 commit comments

Comments
 (0)