Restrict which kind of mutation events are allowed to trigger player refresh
This commit is contained in:
parent
828ded6b29
commit
6af771e1ff
@ -86,19 +86,31 @@ class VideoData {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let confirmAspectRatioRestore = false;
|
||||||
|
|
||||||
for (let mutation of mutationList) {
|
for (let mutation of mutationList) {
|
||||||
if (mutation.type === 'attributes'
|
if (mutation.type === 'attributes') {
|
||||||
&& mutation.attributeName === 'class'
|
if (mutation.attributeName === 'class') {
|
||||||
&& !context.video.classList.contains(this.userCssClassName) ) {
|
if(!context.video.classList.contains(this.userCssClassName) ) {
|
||||||
// force the page to include our class in classlist, if the classlist has been removed
|
// 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),
|
// 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
|
// 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).
|
// 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.
|
// This is a problem because INFINITE RECURSION TIME, and we _really_ don't want that.
|
||||||
|
|
||||||
context.video.classList.add(this.userCssClassName);
|
context.video.classList.add(this.userCssClassName);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
// 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
|
// adding player observer taught us that if element size gets triggered by a class, then
|
||||||
|
Loading…
Reference in New Issue
Block a user