Skip to content

refactor: improve clear() method in DomRenderer to handle text node unwrapping - #36

Merged
saurabhiam merged 3 commits into
mainfrom
chore/core-optimisations
Mar 22, 2026
Merged

refactor: improve clear() method in DomRenderer to handle text node unwrapping#36
saurabhiam merged 3 commits into
mainfrom
chore/core-optimisations

Conversation

@saurabhiam

Copy link
Copy Markdown
Owner
  • Updated the clear() method to unwrap text nodes from wrapper elements more efficiently.
  • Ensured that text nodes are preserved and correctly reinserted into the DOM structure.
  • Enhanced handling of wrapper elements to maintain DOM integrity during the clear operation.

…nwrapping

- Updated the clear() method to unwrap text nodes from wrapper elements more efficiently.
- Ensured that text nodes are preserved and correctly reinserted into the DOM structure.
- Enhanced handling of wrapper elements to maintain DOM integrity during the clear operation.
@saurabhiam saurabhiam self-assigned this Mar 17, 2026
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the clear() method within the DomRenderer to improve how text nodes are unwrapped from their parent wrapper elements. The changes streamline the process by specifically handling single text nodes, ensuring their correct preservation and reinsertion into the DOM, thereby enhancing the overall efficiency and integrity of DOM manipulation operations.

Highlights

  • Optimized Text Node Unwrapping: The clear() method in DomRenderer has been refactored to more efficiently unwrap text nodes, specifically targeting single text nodes created by wrapTextRange.
  • Improved DOM Integrity: The updated logic ensures that text nodes are correctly preserved and reinserted into the DOM structure, enhancing the integrity of the DOM during the clear operation.
  • Streamlined Wrapper Handling: The method now directly handles the wrapper.firstChild for unwrapping, removing a generic loop and adding a check for the existence of the child node before processing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/core/src/engines/dom-renderer.ts
    • Refactored the clear() method to optimize text node unwrapping.
    • Replaced the generic while (wrapper.firstChild) loop with a direct handling of wrapper.firstChild.
    • Added a check to remove empty wrappers and continue processing.
    • Adjusted the matchTextNode reference within the MERGE_NEXT_ATTR block to correctly use the unwrapped first child.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

github-actions Bot commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Package Raw Gzipped Limit
@markitjs/core 27.93 KB 6.90 KB 15 KB
@markitjs/react 3.46 KB 964 B 3 KB
@markitjs/angular 9.26 KB 2.71 KB 5 KB

✅ All packages within size limits

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The DomRenderer.clear() method was refactored to specifically unwrap single text nodes from wrapper elements, assuming wrapTextRange always creates a text node. The reviewer suggests an improvement to remove an unnecessary null check for wrapper.firstChild and use a non-null assertion, as wrapTextRange guarantees the presence of a first child, simplifying the code.

Comment thread packages/core/src/engines/dom-renderer.ts Outdated
…derer

- Updated the DomRenderer to use a non-null assertion for matchTextNode, ensuring it is always defined when unwrapping text nodes from wrapper elements.
- This change improves the reliability of the text node handling during the clear operation.
- Removed the hyperlink from the footer in Layout.vue, simplifying the text to "Made with ♥ in India".
- Added new parameters `iframes` and `iframesTimeout` to the core API documentation, detailing their functionality.
- Clarified the DOM renderer description in the getting started guide to specify behavior when matches occur at the start of text nodes.
- Updated README.md for Angular to reflect the new behavior of the DOM renderer regarding text node handling.
@saurabhiam
saurabhiam merged commit f0abdd6 into main Mar 22, 2026
11 checks passed
@saurabhiam
saurabhiam deleted the chore/core-optimisations branch March 22, 2026 10:40
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