Skip to content

fix: restore instanceof Text and Comment in replace callback - #2406

Merged
remarkablemark merged 1 commit into
remarkablemark:masterfrom
ashwinmridul:fix/instanceof-text-nodes
Sep 17, 2026
Merged

remarkablemark merged 1 commit into
remarkablemark:masterfrom
ashwinmridul:fix/instanceof-text-nodes

Conversation

@ashwinmridul

Copy link
Copy Markdown
Contributor

Summary

  • Fix exported DOM Element instanceof checks #2243 restored instanceof Element by resetting prototypes for tag/script/style nodes, but text and comment nodes were left as plain objects.
  • replace callbacks that check domNode instanceof Text still failed on v6 even with matching domhandler/htmlparser2 versions.
  • Apply the same prototype reset to text and comment nodes, and add a regression covering both.

Test plan

  • npm test (142 tests, 100% coverage)
  • replace callback: domNode instanceof Text is true for text nodes

Fixes #2256

@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0c9092c) to head (a51cbd3).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2406   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          136       143    +7     
  Branches        52        54    +2     
=========================================
+ Hits           136       143    +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@remarkablemark remarkablemark added the bug Something isn't working label Sep 17, 2026
@remarkablemark
remarkablemark merged commit e16b187 into remarkablemark:master Sep 17, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

instanceof Text broken in v6 — exported Text class differs from internal parser Text

2 participants