Skip to content

Add DOM nodeName aliases#1952

Open
aouxwoux wants to merge 1 commit into
fb55:masterfrom
aouxwoux:codex/add-node-name-alias
Open

Add DOM nodeName aliases#1952
aouxwoux wants to merge 1 commit into
fb55:masterfrom
aouxwoux:codex/add-node-name-alias

Conversation

@aouxwoux

@aouxwoux aouxwoux commented Jul 8, 2026

Copy link
Copy Markdown

Summary

Adds a DOM-compatible nodeName alias to domhandler node classes.

domhandler already exposes several DOM-style aliases such as nodeType, parentNode, childNodes, tagName, and attributes. This adds the commonly used nodeName property for text, comment, CDATA, document, processing instruction, and element nodes without changing the existing internal node model.

This is related to #684.

Validation

  • vitest run
  • tsc --noEmit -p tsconfig.eslint.json
  • biome check src/node.ts src/node.spec.ts
  • eslint src/node.ts src/node.spec.ts

Summary by CodeRabbit

  • New Features

    • Added DOM-style nodeName support across node types, including text, comment, CDATA, document, processing instruction, and element nodes.
    • Node names now return familiar DOM values like #text, #comment, #document, and tag or target names where applicable.
  • Bug Fixes

    • Improved error messages when cloning unsupported node types so they now report the expected node name.
  • Tests

    • Added coverage for nodeName aliases and updated cloning-related expectations.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9de069f3-a015-4177-bda8-137e5b011cfc

📥 Commits

Reviewing files that changed from the base of the PR and between af5e1e7 and fbd17c2.

📒 Files selected for processing (2)
  • src/node.spec.ts
  • src/node.ts

📝 Walkthrough

Walkthrough

The Node base class gains an abstract readonly nodeName property, implemented by Text, Comment, ProcessingInstruction, CDATA, Document, and Element to expose DOM-spec-compatible node name aliases. Tests are updated with a nodeName field on the test Doctype class and a new test verifying nodeName values.

Changes

nodeName Property Implementation

Layer / File(s) Summary
Abstract nodeName contract
src/node.ts
Node declares nodeName as an abstract, read-only string property.
Per-type nodeName getters
src/node.ts
Text, Comment, ProcessingInstruction, CDATA, Document, and Element each implement get nodeName() returning fixed DOM tokens or instance-specific names.
Tests for nodeName
src/node.spec.ts
Adds nodeName to the test Doctype class and a new test asserting nodeName values for multiple node types.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A hop, a skip, a name so neat,
Each node now knows its DOM feat.
#text, #comment, #document too,
Elements proudly show their name anew.
🐇 Clap, clap—tests confirm it's true!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely reflects the main change: adding DOM-compatible nodeName aliases.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@aouxwoux aouxwoux marked this pull request as ready for review July 8, 2026 14:54
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

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