Skip to content
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

MutationObserver perfomance and Narrowing actually used text nodes #30

Closed
FrameMuse opened this issue May 10, 2023 · 2 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@FrameMuse
Copy link
Owner

FrameMuse commented May 10, 2023

Problem

Mutations

We want to watch for any changes in elements to handle a possibility of elements that they changed their position or bounds.

For this we use MutationObserver, which is observing everything starting from root element.

If we let to pass any node to the root, it may contain unwanted elements, which may be the Editor elements themselves. So we need to check if a mutation doesn't relate to any of unwanted elements, which may be harmful for perfomance since it should be checked on every mutaiton callback.

Unrelated elements

Custom root element may also contain, elements, which are not localized by i18next, which may be misleading to highlight them. It's also harmful for perfomance since we need to observe for changes of elements are not actually related to the Editor.

Solution

  • Split (and isolate) the Editor elements and root elements.
  • Add a wrapper element to root elements, which will be root element.
@FrameMuse FrameMuse added the enhancement New feature or request label May 10, 2023
@FrameMuse FrameMuse self-assigned this May 10, 2023
@FrameMuse
Copy link
Owner Author

Related to #27

@FrameMuse
Copy link
Owner Author

Updating due to #57, now will be work using createPortal and DocumentFragment without creating a div with all: inherit style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant