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

Add aria-hidden=true to resize-listeners #3949

Merged
merged 2 commits into from
Nov 18, 2019
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Svelte changelog

## Unreleased

* Add `aria-hidden="true"` to objects generated when adding resize-listeners, to improve accessibility ([#3948](https://github.com/sveltejs/svelte/issues/3948))

## 3.14.1

* Deconflict block method names with other variables ([#3900](https://github.com/sveltejs/svelte/issues/3900))
Expand Down
1 change: 1 addition & 0 deletions src/runtime/internal/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export function add_resize_listener(element, fn) {

const object = document.createElement('object');
object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
object.setAttribute('aria-hidden', 'true');
object.type = 'text/html';
object.tabIndex = -1;

Expand Down
8 changes: 8 additions & 0 deletions test/runtime/samples/binding-width-height-a11y/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
async test({ assert, target }) {
const object = target.querySelector('object');

assert.equal(object.getAttribute('aria-hidden'), "true");
assert.equal(object.getAttribute('tabindex'), "-1");
}
};
10 changes: 10 additions & 0 deletions test/runtime/samples/binding-width-height-a11y/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
let offsetWidth = 0;
let offsetHeight = 0;
</script>

<div bind:offsetHeight bind:offsetWidth>

<h1>Hello</h1>

</div>