Repository navigation
fix(title): keep applying title rules when the page replaces <title> - #568
Merged
Merged
Conversation
…566) GitHub replaces the <title> element after load. The title observer was attached to the original element, so once it was detached the rule was never reapplied and the page title won. Observe <head> instead, like the favicon observer already does.
📦 Extension Build Ready!Version: 📥 Download Extension (tabee.zip)Installation
Status
🤖 Auto-generated by GitHub Actions |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #566.
Problem
On GitHub, a rule like
GitHub - {title}is applied for a moment, then the title goes back to GitHub's own.GitHub replaces the whole
<title>element after load.applyTitleRuleattached itsMutationObserverto the<title>element found at load time. Once GitHub swapped it, the observer was watching a detached node, so the new title was never processed.Reproduced on
masterwith Playwright on #557: the rule never applied over 8 seconds, and 2 distinct<title>elements were seen.Fix
Observe
document.head(child list, character data, subtree) instead of the<title>element, as the favicon observer already does. The callback is unchanged: it only acts whendocument.titleactually changed, so our own write doesn't loop. Still far fewer callbacks than observing the whole document.Tests
RuleApplicationService.test.ts(real jsdom DOM): title applied on load, reapplied when the text changes, reapplied when the<title>element is replaced (fails without the fix), and no extra pass triggered by our own write.GitHub - …within 500 ms and stays.vue-tscpass.