mirror of
https://github.com/videojs/video.js.git
synced 2025-03-17 21:18:27 +02:00
fix: warn on element not in DOM even when from another document (#5831)
This commit is contained in:
parent
ea8c42691a
commit
237b68b561
@ -4,7 +4,6 @@
|
||||
*/
|
||||
import {version} from '../../package.json';
|
||||
import window from 'global/window';
|
||||
import document from 'global/document';
|
||||
import * as setup from './setup';
|
||||
import * as stylesheet from './utils/stylesheet.js';
|
||||
import Component from './component';
|
||||
@ -143,7 +142,13 @@ function videojs(id, options, ready) {
|
||||
throw new TypeError('The element or ID supplied is not valid. (videojs)');
|
||||
}
|
||||
|
||||
if (!document.body.contains(el)) {
|
||||
// document.contains(el) will only check if el is contained within that one document.
|
||||
// This causes problems for elements in iframes.
|
||||
// Instead, use the element's ownerDocument instead of the global document.
|
||||
// This will make sure that the element is indeed in the dom of that document.
|
||||
// Additionally, check that the document in question has a default view.
|
||||
// If the document is no longer attached to the dom, the defaultView of the document will be null.
|
||||
if (!el.ownerDocument.defaultView || !el.ownerDocument.contains(el)) {
|
||||
log.warn('The element supplied is not included in the DOM');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user