1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-19 10:54:16 +02:00

perf: fix an event target memory leak (#5855)

This commit is contained in:
Brandon Casey 2019-03-18 15:40:55 -04:00 committed by Gary Katsevman
parent 6eb9fd3dfb
commit 20bf42d8b9
3 changed files with 10 additions and 3 deletions

View File

@ -138,6 +138,11 @@ EventTarget.prototype.one = function(type, fn) {
EventTarget.prototype.trigger = function(event) {
const type = event.type || event;
// deprecation
// In a future version we should default target to `this`
// similar to how we default the target to `elem` in
// `Events.trigger`. Right now the default `target` will be
// `document` due to the `Event.fixEvent` call.
if (typeof event === 'string') {
event = {type};
}

View File

@ -72,7 +72,8 @@ class TrackList extends EventTarget {
*/
this.trigger({
track,
type: 'addtrack'
type: 'addtrack',
target: this
});
}
}
@ -115,7 +116,8 @@ class TrackList extends EventTarget {
*/
this.trigger({
track,
type: 'removetrack'
type: 'removetrack',
target: this
});
}

View File

@ -431,7 +431,7 @@ export function trigger(elem, event, hash) {
trigger.call(null, parent, event, hash);
// If at the top of the DOM, triggers the default action unless disabled.
} else if (!parent && !event.defaultPrevented) {
} else if (!parent && !event.defaultPrevented && event.target && event.target[event.type]) {
const targetData = DomData.getData(event.target);
// Checks if the target has a default action for this event.