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

2 split the code #75

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

katsyuta
Copy link

#2

What problem does this pull request solve?

The NodeTranslator class is large and complex, making it difficult to understand.
- When a problem occurs, it is difficult to localize the issue because the class is large and contains many complex interactions between different private fields. The solution to the problem will take more time.
- The code is hard to understand, so developers will have to spend more time reading and comprehending it.

Key changes:

  • Extracted logic for working with IntersectionObserver and node translation from the DomTranslator class.
    As a result, three classes were created:
    • LazyTranslator – encapsulates IntersectionObserver logic; its purpose is to translate nodes lazily when they enter the veiwport.
    • DomTranslationProcessor – responsible for translating nodes, containing logic for priority determination, prevent repeated translation, methods for managing node translation, and everything necessary for translation. (Internally uses methods from the LazyTranslator class lazy translation)
    • NodeTranslator – connects the previous two classes and provides methods for DOM translation.
  • Utility functions have been moved to the utils directory.
  • Add test for classes

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

Successfully merging this pull request may close these issues.

1 participant