fix #684 memory leaks issues after destroy.
This commit is contained in:
parent
b3759e966d
commit
7234e2f5a3
@ -519,11 +519,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unbind event
|
// Unbind event
|
||||||
/*function _off(element, events, callback, useCapture) {
|
function _off(element, events, callback, useCapture) {
|
||||||
if (element) {
|
if (element) {
|
||||||
_toggleListener(element, events, callback, false, useCapture);
|
_toggleListener(element, events, callback, false, useCapture);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// Trigger event
|
// Trigger event
|
||||||
function _event(element, type, bubbles, properties) {
|
function _event(element, type, bubbles, properties) {
|
||||||
@ -2931,6 +2931,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onBodyClick() {
|
||||||
|
_toggleClass(_getElement('.' + config.classes.tabFocus), config.classes.tabFocus, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Listen for control events
|
// Listen for control events
|
||||||
function _controlListeners() {
|
function _controlListeners() {
|
||||||
// IE doesn't support input event, so we fallback to change
|
// IE doesn't support input event, so we fallback to change
|
||||||
@ -3145,9 +3149,7 @@
|
|||||||
checkTabFocus(focused);
|
checkTabFocus(focused);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_on(document.body, "click", function() {
|
_on(document.body, "click", onBodyClick);
|
||||||
_toggleClass(_getElement("." + config.classes.tabFocus), config.classes.tabFocus, false);
|
|
||||||
});
|
|
||||||
for (var button in plyr.buttons) {
|
for (var button in plyr.buttons) {
|
||||||
var element = plyr.buttons[button];
|
var element = plyr.buttons[button];
|
||||||
|
|
||||||
@ -3429,9 +3431,15 @@
|
|||||||
// Replace the container with the original element provided
|
// Replace the container with the original element provided
|
||||||
plyr.container.parentNode.replaceChild(original, plyr.container);
|
plyr.container.parentNode.replaceChild(original, plyr.container);
|
||||||
|
|
||||||
|
// Free container in order for GC to remove it and prevent memory leaks due to added events
|
||||||
|
plyr.container = null;
|
||||||
|
|
||||||
// Allow overflow (set on fullscreen)
|
// Allow overflow (set on fullscreen)
|
||||||
document.body.style.overflow = "";
|
document.body.style.overflow = "";
|
||||||
|
|
||||||
|
//remove events
|
||||||
|
_off(document.body, 'click', onBodyClick);
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
_triggerEvent(original, "destroyed", true);
|
_triggerEvent(original, "destroyed", true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user