-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Muting with MuteToggle
sets ARIA value of VolumeBar
to 0
#4099
Merged
gkatsev
merged 9 commits into
videojs:master
from
kevinlitchfield:fix-aria-value-of-volumebar-after-mute
Feb 21, 2017
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f1f6451
Muting with MuteToggle sets ARIA value of VolumeBar to 0
kevinlitchfield da8516d
Fix linting errors
kevinlitchfield 0c5f3cc
Refactor updateARIAAttributes
kevinlitchfield 6309a76
Use Sinon's fake timers
kevinlitchfield 0dabd59
Fix linting errors
kevinlitchfield c3ebcc7
Refactor volumeAsPercentage_
kevinlitchfield c963d02
Trigger 'volumechange' instead of updateARIAAttributes
kevinlitchfield 2b8f064
Add explanatory comment
kevinlitchfield 80fb9d9
Fix comment
kevinlitchfield File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,11 +105,19 @@ class VolumeBar extends Slider { | |
* @listens Player#volumechange | ||
*/ | ||
updateARIAAttributes(event) { | ||
// Current value of volume bar as a percentage | ||
const volume = Math.round((this.player_.volume() * 100)).toString(); | ||
const ariaValue = this.player_.muted() ? 0 : this.volumeAsPercentage_(); | ||
|
||
this.el_.setAttribute('aria-valuenow', volume); | ||
this.el_.setAttribute('aria-valuetext', volume + '%'); | ||
this.el_.setAttribute('aria-valuenow', ariaValue); | ||
this.el_.setAttribute('aria-valuetext', ariaValue + '%'); | ||
} | ||
|
||
/** | ||
* Returns the current value of the player volume as a percentage | ||
* | ||
* @private | ||
*/ | ||
volumeAsPercentage_() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
return Math.round(this.player_.volume() * 100); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it matter that you haven't converted
ariaValue
to a string by this point (where the previous code used the.toString()
method on the numeric value)? According to Using the aria-valuenow attribute - Accessibility | MDN, the value should be "String representation of a number". (Thearia-valuetext
will become a string thanks to the+ '%'
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OwenEdwards Thanks for the suggestion. I don't think this does matter, though. The number gets coerced to a string when being set on the element even without
+ '%'
there to more visibly do the coercion. Tried changing everything to strings just in case and there was no difference.