You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cloning an XML script or style element currently changes its type from tag to script or style. DomHandler deliberately creates these elements as ordinary tags in XML mode, but cloneNode reconstructs them without the original type and the Element constructor infers HTML-specific types from their names.
Pass the original type to the constructor. Parser-based regressions cover both element names, shallow clones, and deep document clones; the existing HTML clone tests continue to pass.
Testing
Validation on Node 24.13.0: both new cases fail before the change; npm test passes all 35 tests and the complete ESLint, TypeScript, and Biome checks. npm run build passes. Biome reports two existing configuration-migration notices; no configuration changes are included.
Breaking Changes
None.
Prepared and validated with OpenAI Codex assistance.
Manual verification: Parse a script or style element in XML mode and clone it; both the shallow element and deep tree clone should preserve ElementType.Tag.
Summary by CodeRabbit
Bug Fixes
Cloned XML script and style elements now retain their original element type. This keeps shallow-cloned elements correctly identified and ensures deep-cloned results match the source, improving consistency when working with these elements. XML parsing and cloning now preserve the distinction between regular tags, scripts, and styles.
No actionable comments were generated in the recent review.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: a86fe4ea-5214-4e46-9c07-03a3760e059e
Commits
Reviewing files that changed from the base of the PR and between efb8d49 and cadf1b9.
Files selected for processing: 2
src/node.spec.ts
src/node.ts
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
Walkthrough
cloneNode now passes the source element’s type to the Element constructor. XML-mode tests cover parsing and cloning script and style elements.
Changes: Element clone type preservation
Layer / File(s)
Summary
Preserve and test element type src/node.ts, src/node.spec.ts
cloneNode passes the source element’s type to the constructor. XML-mode tests check that parsed script and style elements and their shallow clones have ElementType.Tag, and that a deep clone is strictly equal to the original.
No actionable merge-blocking risk is evident from the supplied change and tests.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: preserving XML element types during cloning.
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
src/node.spec.ts
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
src/node.ts
ESLint skipped: the matched ESLint configuration already failed (missing-dependency).
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks each cloned tag, Then hops through XML with a wag. Script and style keep their type, Deep copies match just right. The bunny’s done; it guards the bag.
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
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.
Summary
Cloning an XML
scriptorstyleelement currently changes its type fromtagtoscriptorstyle. DomHandler deliberately creates these elements as ordinary tags in XML mode, butcloneNodereconstructs them without the original type and the Element constructor infers HTML-specific types from their names.Pass the original type to the constructor. Parser-based regressions cover both element names, shallow clones, and deep document clones; the existing HTML clone tests continue to pass.
Testing
Validation on Node 24.13.0: both new cases fail before the change;
npm testpasses all 35 tests and the complete ESLint, TypeScript, and Biome checks.npm run buildpasses. Biome reports two existing configuration-migration notices; no configuration changes are included.Breaking Changes
None.
Prepared and validated with OpenAI Codex assistance.
Manual verification: Parse a script or style element in XML mode and clone it; both the shallow element and deep tree clone should preserve ElementType.Tag.
Summary by CodeRabbit
scriptandstyleelements now retain their original element type. This keeps shallow-cloned elements correctly identified and ensures deep-cloned results match the source, improving consistency when working with these elements. XML parsing and cloning now preserve the distinction between regular tags, scripts, and styles.