mirror of
https://github.com/videojs/video.js.git
synced 2025-02-04 11:43:27 +02:00
fix: Events#off threw if Object.prototype had extra enumerable properties, don't remove all events if off receives a falsey value (#4669)
If Object.prototype was modified to have extra properties, the `off` method crashed because `data.handlers` would've been removed before getting to the extra property. Also, this fixes an issue where if a falsey value was passed to off, the events system would remove all the events, i.e. `player.off('')`. Instead, we make sure that only if it is called as `player.off()` will they be removed.
This commit is contained in:
parent
afea980174
commit
79639138ba
@ -350,9 +350,11 @@ export function off(elem, type, fn) {
|
||||
};
|
||||
|
||||
// Are we removing all bound events?
|
||||
if (!type) {
|
||||
if (type === undefined) {
|
||||
for (const t in data.handlers) {
|
||||
removeType(t);
|
||||
if (Object.prototype.hasOwnProperty.call(data.handlers || {}, t)) {
|
||||
removeType(t);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user