aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js/controls.js3
-rw-r--r--src/js/plyr.js2
-rw-r--r--src/js/utils.js29
3 files changed, 20 insertions, 14 deletions
diff --git a/src/js/controls.js b/src/js/controls.js
index 4f6ef365..0759492b 100644
--- a/src/js/controls.js
+++ b/src/js/controls.js
@@ -1134,8 +1134,7 @@ const controls = {
// Larger overlaid play button
if (this.config.controls.includes('play-large')) {
- this.elements.buttons.playLarge = controls.createButton.call(this, 'play-large');
- this.elements.container.appendChild(this.elements.buttons.playLarge);
+ this.elements.container.appendChild(controls.createButton.call(this, 'play-large'));
}
this.elements.controls = container;
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 08e722c1..09b2aa8a 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -890,12 +890,14 @@ class Plyr {
// If it's a soft destroy, make minimal changes
if (soft) {
utils.removeElement(this.elements.captions);
+ Array.from(this.elements.buttons.play).forEach(button => utils.removeElement(button));
utils.removeElement(this.elements.controls);
utils.removeElement(this.elements.wrapper);
// Clear for GC
this.elements.captions = null;
this.elements.controls = null;
+ this.elements.buttons.play = null;
this.elements.wrapper = null;
// Callback
diff --git a/src/js/utils.js b/src/js/utils.js
index 1c3d6ed8..02f97d5a 100644
--- a/src/js/utils.js
+++ b/src/js/utils.js
@@ -433,7 +433,7 @@ const utils = {
// Trap focus inside container
trapFocus() {
- const tabbables = utils.getElements.call(this, 'input:not([disabled]), button:not([disabled])');
+ const tabbables = utils.getElements.call(this, 'button:not(:disabled), input:not(:disabled), [tabindex]');
const first = tabbables[0];
const last = tabbables[tabbables.length - 1];
@@ -441,17 +441,22 @@ const utils = {
this.elements.container,
'keydown',
event => {
- // If it is tab
- if (event.which === 9 && this.fullscreen.active) {
- if (event.target === last && !event.shiftKey) {
- // Move focus to first element that can be tabbed if Shift isn't used
- event.preventDefault();
- first.focus();
- } else if (event.target === first && event.shiftKey) {
- // Move focus to last element that can be tabbed if Shift is used
- event.preventDefault();
- last.focus();
- }
+ // Bail if not tab key or not fullscreen
+ if (event.key !== 'Tab' || event.keyCode !== 9 || !this.fullscreen.active) {
+ return;
+ }
+
+ // Get the current focused element
+ const focused = utils.getFocusElement();
+
+ if (focused === last && !event.shiftKey) {
+ // Move focus to first element that can be tabbed if Shift isn't used
+ first.focus();
+ event.preventDefault();
+ } else if (focused === first && event.shiftKey) {
+ // Move focus to last element that can be tabbed if Shift is used
+ last.focus();
+ event.preventDefault();
}
},
false