1
0
mirror of https://github.com/videojs/video.js.git synced 2025-03-17 21:18:27 +02:00

fix: use ownerDocument.body.contains for IE11 (#5872)

Issue #5831 made the not-in-DOM warning work with elements from other
documents. This works in modern browsers but IE11 doesn't include a
contains method on the document. Instead, we should check to see if the
body contains the element.
This commit is contained in:
Gary Katsevman 2019-03-18 15:15:15 -04:00 committed by GitHub
parent e248286fb6
commit 4169ddd9b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,13 +142,13 @@ function videojs(id, options, ready) {
throw new TypeError('The element or ID supplied is not valid. (videojs)');
}
// document.contains(el) will only check if el is contained within that one document.
// document.body.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)) {
if (!el.ownerDocument.defaultView || !el.ownerDocument.body.contains(el)) {
log.warn('The element supplied is not included in the DOM');
}