aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/controls.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-04-18 18:29:43 +1000
committerSam Potts <sam@potts.es>2018-04-18 18:29:43 +1000
commita97b08e8ea0022646eae005ce64a7edf8b26fb29 (patch)
tree5cbf4ec5cfcfb5c22d4ae8143ea52a7a888eb276 /src/js/controls.js
parent88d766aeae6084dccd1903c2c358b8d1dfdfbce0 (diff)
downloadplyr-a97b08e8ea0022646eae005ce64a7edf8b26fb29.tar.lz
plyr-a97b08e8ea0022646eae005ce64a7edf8b26fb29.tar.xz
plyr-a97b08e8ea0022646eae005ce64a7edf8b26fb29.zip
ARIA and Vimeo fixes
Diffstat (limited to 'src/js/controls.js')
-rw-r--r--src/js/controls.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/js/controls.js b/src/js/controls.js
index 05d98bab..ce4c17ee 100644
--- a/src/js/controls.js
+++ b/src/js/controls.js
@@ -15,10 +15,7 @@ const browser = utils.getBrowser();
const controls = {
// Webkit polyfill for lower fill range
updateRangeFill(target) {
- // WebKit only
- if (!browser.isWebkit) {
- return;
- }
+
// Get range from event if event passed
const range = utils.is.event(target) ? target.target : target;
@@ -28,6 +25,14 @@ const controls = {
return;
}
+ // Set aria value for https://github.com/sampotts/plyr/issues/905
+ range.setAttribute('aria-valuenow', range.value);
+
+ // WebKit only
+ if (!browser.isWebkit) {
+ return;
+ }
+
// Set CSS custom property
range.style.setProperty('--value', `${range.value / range.max * 100}%`);
},
@@ -238,6 +243,7 @@ const controls = {
'label',
{
for: attributes.id,
+ id: `${attributes.id}-label`,
class: this.config.classNames.hidden,
},
i18n.get(type, this.config),
@@ -255,6 +261,12 @@ const controls = {
step: 0.01,
value: 0,
autocomplete: 'off',
+ // A11y fixes for https://github.com/sampotts/plyr/issues/905
+ role: 'slider',
+ 'aria-labelledby': `${attributes.id}-label`,
+ 'aria-valuemin': 0,
+ 'aria-valuemax': 100,
+ 'aria-valuenow': 0,
},
attributes,
),