1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-02 06:32:07 +02:00

fix: check for closeable() before calling in spatialnavigation (#8832)

## Description
Passing the back key causes an error in spatial navigation if the event
target does not have a `closeable` function.

## Specific Changes proposed
Add a check before calling.
This commit is contained in:
mister-ben 2024-08-28 15:44:38 +02:00 committed by GitHub
parent 5fac9e1e9d
commit 8c56e31cad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -120,7 +120,8 @@ class SpatialNavigation extends EventTarget {
const action = SpatialNavKeyCodes.getEventName(actualEvent); const action = SpatialNavKeyCodes.getEventName(actualEvent);
this.performMediaAction_(action); this.performMediaAction_(action);
} else if (SpatialNavKeyCodes.isEventKey(actualEvent, 'Back') && event.target && event.target.closeable()) { } else if (SpatialNavKeyCodes.isEventKey(actualEvent, 'Back') &&
event.target && typeof event.target.closeable === 'function' && event.target.closeable()) {
actualEvent.preventDefault(); actualEvent.preventDefault();
event.target.close(); event.target.close();
} }