Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove role attribute when it's null or undefined #4137

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
name !== 'download' &&
name !== 'rowSpan' &&
name !== 'colSpan' &&
name !== 'role' &&
name in dom
) {
try {
Expand Down
17 changes: 17 additions & 0 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1281,4 +1281,21 @@ describe('render()', () => {
render(<div tabindex={null} />, scratch);
expect(scratch.firstChild.tabIndex).to.equal(defaultValue);
});

// #4137
it('should unset role if null || undefined', () => {
render(
<section>
<div role="status">role="status"</div>
<div role={undefined}>role="undefined"</div>
<div role={null}>role="null"</div>
</section>,
scratch
);

const divs = scratch.querySelectorAll('div');
expect(divs[0].hasAttribute('role')).to.equal(true);
expect(divs[1].hasAttribute('role')).to.equal(false);
expect(divs[2].hasAttribute('role')).to.equal(false);
});
});
Loading