-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix subtitles not added to DOM region #4733
fix: Fix subtitles not added to DOM region #4733
Conversation
Incremental code coverage: 85.71% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good fix overall. Thanks! If I have permission to edit, I'll make the change I suggested.
lib/text/ui_text_displayer.js
Outdated
if (elemToCheck == this.textContainer_) { | ||
return true; | ||
} | ||
return this.isElementUnderTextContainer_(elemToCheck.parentElement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With only one parent element, I think this could be rewritten as a while loop and be slightly more efficient that way.
https://jsbench.me/ suggests it would be 10% faster, though admittedly I did put the target element 100 levels deep in my test case.
Setup:
const myContainer = document.createElement('div');
let innerHTML = '<span id="myTarget"></span>';
for (i = 0; i < 100; i++) {
innerHTML = `<span>${innerHTML}</span>`;
}
myContainer.innerHTML = innerHTML;
document.body.appendChild(myContainer);
Recursive:
function v1(thing, ancestor) {
if (thing == null) {
return false;
}
if (thing == ancestor) {
return true;
}
return v1(thing.parentElement, ancestor);
}
console.log(v1(myTarget, document.body));
Loop:
function v2(thing, ancestor) {
while (thing != null) {
if (thing == ancestor) {
return true;
}
thing = thing.parentElement;
}
return false;
}
console.log(v2(myTarget, document.body));
Reinstate previously removed region elements when next caption finds it is not there: Detect the absence and ensure `updateDOM` is true so its reinstated and the next caption can be shown. Closes #4680 Co-authored-by: Joey Parrish <[email protected]>
Reinstate previously removed region elements when next caption finds it is not there: Detect the absence and ensure `updateDOM` is true so its reinstated and the next caption can be shown. Closes #4680 Co-authored-by: Joey Parrish <[email protected]>
Reinstate previously removed region elements when next caption finds it is not there: Detect the absence and ensure `updateDOM` is true so its reinstated and the next caption can be shown. Closes #4680 Co-authored-by: Joey Parrish <[email protected]>
Reinstate previously removed region elements when next caption finds it is not there: Detect the absence and ensure `updateDOM` is true so its reinstated and the next caption can be shown. Closes #4680 Co-authored-by: Joey Parrish <[email protected]>
Reinstate previously removed region elements when next caption finds it is not there: Detect the absence and ensure `updateDOM` is true so its reinstated and the next caption can be shown. Closes #4680 Co-authored-by: Joey Parrish <[email protected]>
Proposed fix closes #4680
Reinstate previously removed region elements when next caption finds it is not there: Detect the absence and ensure
updateDOM
is true so its reinstated and the next caption can be shown.