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:
parent
6eb9fd3dfb
commit
20bf42d8b9
@ -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};
|
||||
}
|
||||
|
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user