diff --git a/src/ext/lib/video-data/VideoData.js b/src/ext/lib/video-data/VideoData.js index 3ec36cc..d343f6d 100644 --- a/src/ext/lib/video-data/VideoData.js +++ b/src/ext/lib/video-data/VideoData.js @@ -86,21 +86,33 @@ class VideoData { } return; } + let confirmAspectRatioRestore = false; + for (let mutation of mutationList) { - if (mutation.type === 'attributes' - && mutation.attributeName === 'class' - && !context.video.classList.contains(this.userCssClassName) ) { - // force the page to include our class in classlist, if the classlist has been removed - // while classList.add() doesn't duplicate classes (does nothing if class is already added), - // we still only need to make sure we're only adding our class to classlist if it has been - // removed. classList.add() will _still_ trigger mutation (even if classlist wouldn't change). - // This is a problem because INFINITE RECURSION TIME, and we _really_ don't want that. - - context.video.classList.add(this.userCssClassName); - break; + if (mutation.type === 'attributes') { + if (mutation.attributeName === 'class') { + if(!context.video.classList.contains(this.userCssClassName) ) { + // force the page to include our class in classlist, if the classlist has been removed + // while classList.add() doesn't duplicate classes (does nothing if class is already added), + // we still only need to make sure we're only adding our class to classlist if it has been + // removed. classList.add() will _still_ trigger mutation (even if classlist wouldn't change). + // This is a problem because INFINITE RECURSION TIME, and we _really_ don't want that. + context.video.classList.add(this.userCssClassName); + } + // always trigger refresh on class changes, since change of classname might trigger change + // of the player size as well. + confirmAspectRatioRestore = true; + } + if (mutation.attributeName === 'style') { + confirmAspectRatioRestore = true; + } } } + if (!confirmAspectRatioRestore) { + return; + } + // adding player observer taught us that if element size gets triggered by a class, then // the 'style' attributes don't necessarily trigger. This means we also need to trigger // restoreAr here, in case video size was changed this way