Skip to content

Commit ea7d35c

Browse files
eryue0220ematipico
andauthored
fix(lint/noInteractiveElementToNoninteractiveRole): fix <source /> error case (#4300)
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
1 parent 5a1710f commit ea7d35c

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
1717

1818
- Improved the message for unused suppression comments. Contributed by @dyc3
1919

20+
- Fix [#4228](https://github.com/biomejs/biome/issues/4228), where the rule `a11y/noInteractiveElementToNoninteractiveRole` incorrectlly reports a `role` for non interactive elements. Contributed by @eryue0220
2021
- Catch suspicious semicolon in react fragment in `noSuspiciousSemicolonInJsx`. Contributed by @vasucp1207
2122

2223
### CLI

crates/biome_js_analyze/src/lint/a11y/no_interactive_element_to_noninteractive_role.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl Rule for NoInteractiveElementToNoninteractiveRole {
6868
{
6969
// <div> and <span> are considered neither interactive nor non-interactive, depending on the presence or absence of the role attribute.
7070
// We don't report <div> and <span> here, because we cannot determine whether they are interactive or non-interactive.
71-
let role_sensitive_elements = ["div", "span"];
71+
let role_sensitive_elements = ["div", "span", "source"];
7272
if role_sensitive_elements.contains(&element_name.text_trimmed()) {
7373
return None;
7474
}

crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx

+11
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,15 @@
264264
<Link href="http://x.y.z" role="img" />;
265265
<Link href="http://x.y.z" />;
266266
<Button onClick={doFoo} />;
267+
<picture>
268+
<source
269+
srcSet={'/assets/head.webp'}
270+
role='img'
271+
type='image/webp'
272+
/>
273+
<img
274+
src={'/assets/head.png'}
275+
alt='An ASCII-style headshot'
276+
/>
277+
</picture>
267278

crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx.snap

+11
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,17 @@ expression: valid.jsx
271271
<Link href="http://x.y.z" role="img" />;
272272
<Link href="http://x.y.z" />;
273273
<Button onClick={doFoo} />;
274+
<picture>
275+
<source
276+
srcSet={'/assets/head.webp'}
277+
role='img'
278+
type='image/webp'
279+
/>
280+
<img
281+
src={'/assets/head.png'}
282+
alt='An ASCII-style headshot'
283+
/>
284+
</picture>
274285
275286
276287
```

0 commit comments

Comments
 (0)