mirror of
https://github.com/videojs/video.js.git
synced 2025-01-02 06:32:07 +02:00
fix: prevent error for root shadow elements when restorEl is enabled (#8679)
Addresses an issue where activating the `restoreEl` option for an element at the root of a shadow DOM threw a "TypeError: el.parentNode.hasAttribute is not a function". The bug was due to the `parentNode` being a shadow root, which does not have the `hasAttribute` method. The fix implemented checks for the existence of the `hasAttribute` method on `parentNode`.
This commit is contained in:
parent
992af3b3ee
commit
31b037891b
@ -167,7 +167,7 @@ function videojs(id, options, ready) {
|
||||
// Store a copy of the el before modification, if it is to be restored in destroy()
|
||||
// If div ingest, store the parent div
|
||||
if (options.restoreEl === true) {
|
||||
options.restoreEl = (el.parentNode && el.parentNode.hasAttribute('data-vjs-player') ? el.parentNode : el).cloneNode(true);
|
||||
options.restoreEl = (el.parentNode && el.parentNode.hasAttribute && el.parentNode.hasAttribute('data-vjs-player') ? el.parentNode : el).cloneNode(true);
|
||||
}
|
||||
|
||||
hooks('beforesetup').forEach((hookFunction) => {
|
||||
|
Loading…
Reference in New Issue
Block a user