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

Attach handlers to ownerDocument, not document #3230

Closed
Closed
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
3 changes: 1 addition & 2 deletions src/js/control-bar/volume-menu-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Popup from '../popup/popup.js';
import PopupButton from '../popup/popup-button.js';
import MuteToggle from './mute-toggle.js';
import VolumeBar from './volume-control/volume-bar.js';
import document from 'global/document';

/**
* Button for volume popup
Expand Down Expand Up @@ -131,7 +130,7 @@ class VolumeMenuButton extends PopupButton {

handleMouseDown(event) {
this.on(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove));
this.on(document, ['mouseup', 'touchend'], this.handleMouseUp);
this.on(this.el_.ownerDocument, ['mouseup', 'touchend'], this.handleMouseUp);
}

handleMouseUp(event) {
Expand Down
6 changes: 2 additions & 4 deletions src/js/modal-dialog.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @file modal-dialog.js
*/
import document from 'global/document';

import * as Dom from './utils/dom';
import * as Fn from './utils/fn';
import log from './utils/log';
Expand Down Expand Up @@ -175,7 +173,7 @@ class ModalDialog extends Component {
}

if (this.closeable()) {
this.on(document, 'keydown', Fn.bind(this, this.handleKeyPress));
this.on(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress));
}

player.controls(false);
Expand Down Expand Up @@ -221,7 +219,7 @@ class ModalDialog extends Component {
}

if (this.closeable()) {
this.off(document, 'keydown', Fn.bind(this, this.handleKeyPress));
this.off(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress));
}

player.controls(true);
Expand Down
25 changes: 14 additions & 11 deletions src/js/slider/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import Component from '../component.js';
import * as Dom from '../utils/dom.js';
import document from 'global/document';
import assign from 'object.assign';

/**
Expand Down Expand Up @@ -68,16 +67,18 @@ class Slider extends Component {
* @method handleMouseDown
*/
handleMouseDown(event) {
let doc = this.bar.el_.ownerDocument;

event.preventDefault();
Dom.blockTextSelection();

this.addClass('vjs-sliding');
this.trigger('slideractive');

this.on(document, 'mousemove', this.handleMouseMove);
this.on(document, 'mouseup', this.handleMouseUp);
this.on(document, 'touchmove', this.handleMouseMove);
this.on(document, 'touchend', this.handleMouseUp);
this.on(doc, 'mousemove', this.handleMouseMove);
this.on(doc, 'mouseup', this.handleMouseUp);
this.on(doc, 'touchmove', this.handleMouseMove);
this.on(doc, 'touchend', this.handleMouseUp);

this.handleMouseMove(event);
}
Expand All @@ -95,15 +96,17 @@ class Slider extends Component {
* @method handleMouseUp
*/
handleMouseUp() {
let doc = this.bar.el_.ownerDocument;

Dom.unblockTextSelection();

this.removeClass('vjs-sliding');
this.trigger('sliderinactive');

this.off(document, 'mousemove', this.handleMouseMove);
this.off(document, 'mouseup', this.handleMouseUp);
this.off(document, 'touchmove', this.handleMouseMove);
this.off(document, 'touchend', this.handleMouseUp);
this.off(doc, 'mousemove', this.handleMouseMove);
this.off(doc, 'mouseup', this.handleMouseUp);
this.off(doc, 'touchmove', this.handleMouseMove);
this.off(doc, 'touchend', this.handleMouseUp);

this.update();
}
Expand Down Expand Up @@ -166,7 +169,7 @@ class Slider extends Component {
* @method handleFocus
*/
handleFocus() {
this.on(document, 'keydown', this.handleKeyPress);
this.on(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress);
}

/**
Expand All @@ -191,7 +194,7 @@ class Slider extends Component {
* @method handleBlur
*/
handleBlur() {
this.off(document, 'keydown', this.handleKeyPress);
this.off(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress);
}

/**
Expand Down