web: Fix possible issue with iframe elements no longer existing in the DOM

This commit is contained in:
Toad06 2020-12-05 16:48:19 +01:00 committed by Mike Welsh
parent 1e61093e32
commit 4ed2470068
1 changed files with 5 additions and 1 deletions

View File

@ -123,6 +123,10 @@ async function injectRuffle(
let elementDocument: HTMLDocument;
try {
elementDocument = elementWindow.document;
if (!elementDocument) {
// Don't polyfill if the window has no document: the element may have been removed from the parent window.
return;
}
} catch (err) {
if (!isExtension) {
console.warn(errorMessage + err);
@ -156,7 +160,7 @@ async function injectRuffle(
// Merge parent window and frame configurations, will likely be applied too late though.
elementWindow.RufflePlayer.config = {
...globalConfig,
...(elementWindow.RufflePlayer?.config ?? {}),
...(elementWindow.RufflePlayer.config ?? {}),
};
}
}