Merge pull request #1416 from emielbeinema/fix_webcomponents

Make menu work in WebComponent
This commit is contained in:
Sam Potts 2019-04-15 21:41:23 +10:00 committed by GitHub
commit 9c1060d9b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
src/js/controls.js vendored
View File

@ -1138,7 +1138,9 @@ const controls = {
} else if (is.keyboardEvent(input) && input.which === 27) { } else if (is.keyboardEvent(input) && input.which === 27) {
show = false; show = false;
} else if (is.event(input)) { } else if (is.event(input)) {
const isMenuItem = popup.contains(input.target); // If Plyr is in a shadowDOM, the event target is set to the component, instead of the
// element in the shadowDOM. The path, however, is complete.
const isMenuItem = popup.contains(input.path[0]);
// If the click was inside the menu or if the click // If the click was inside the menu or if the click
// wasn't the button or menu item and we're trying to // wasn't the button or menu item and we're trying to
@ -1191,7 +1193,7 @@ const controls = {
// Show a panel in the menu // Show a panel in the menu
showMenuPanel(type = '', tabFocus = false) { showMenuPanel(type = '', tabFocus = false) {
const target = document.getElementById(`plyr-settings-${this.id}-${type}`); const target = this.elements.container.querySelector(`#plyr-settings-${this.id}-${type}`);
// Nothing to show, bail // Nothing to show, bail
if (!is.element(target)) { if (!is.element(target)) {