Conversation
Contributor
Author
|
What do you think @eemeli ? |
…tion observer This is a workaround for issue projectfluent#648. In apps that are primarily implemented with WebComponents, the number of roots can grow a lot. This proved to be a performance issue. So instead of using a MutationObserver to run translations, the WebComponent framework can call the translate functions directly as part of its lifecycle.
julienw
force-pushed
the
support-opting-out-mutation-observer
branch
from
September 15, 2026 12:36
73318b4 to
b834edc
Compare
julienw
commented
Sep 15, 2026
| connectRoot(newRoot, opts = {}) { | ||
| const useObserver = "useObserver" in opts ? opts.useObserver : true; // Defaults to true | ||
|
|
||
| for (const root of this.roots) { |
Contributor
Author
There was a problem hiding this comment.
I notice that this loop is also quadratic when a lot of roots are added, and it's very unlikely for Lit-based apps, plus the drawbacks of not doing this check is very low if I understand this correctly (again, in a lit-based app where each root has a small DOM).
Maybe a better solution would be a separate localization class... I'll look into that.
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.
This is a workaround for issue #648.
In apps that are primarily implemented with WebComponents, the number of roots can grow a lot. This proved to be a performance issue. So instead of using a MutationObserver to run translations, the WebComponent framework can call the translate functions directly as part of its lifecycle.