Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 26, 2025

Implements the missing document.createComment() DOM API method in the JSAR runtime. Previously, the method was declared in the JavaScript bindings but returned undefined instead of creating Comment nodes.

Changes Made

Core Implementation

  • Document class: Added createComment(const std::string &data) method that creates Comment nodes with the specified text content and proper owner document reference
  • JavaScript binding: Updated CreateComment method to properly validate arguments, create Comment nodes, and return them to JavaScript with appropriate error handling
  • Include dependencies: Added necessary Comment class includes to both header and implementation files

DOM Integration

  • Serialization support: Implemented Comment node serialization in HTMLDocument::SerializeFragment() to output proper HTML comment format (<!--content-->)
  • Tree operations: Comment nodes now fully integrate with DOM tree operations like appendChild(), insertBefore(), etc.

Testing

  • Added comprehensive test suite covering comment creation, node properties, DOM tree integration, and HTML serialization
  • Tests verify compliance with Web API standards for node type, name, and content handling

API Usage

// Create a comment node
const comment = document.createComment('This is a comment');

// Add to DOM tree
document.body.appendChild(comment);

// Serializes correctly as HTML
console.log(document.body.innerHTML); // Contains <!--This is a comment-->

The implementation follows the MDN specification and DOM Standard, ensuring Comment nodes have correct properties (nodeType: COMMENT_NODE, nodeName: "#comment") and behavior.

Fixes #232.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • registry.npmmirror.com
    • Triggering command: npm ci (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Implement document.createComment() in client/dom and related files Implement document.createComment() in client/dom and related files Aug 26, 2025
Copilot AI requested a review from yorkie August 26, 2025 12:41
@yorkie yorkie marked this pull request as ready for review August 26, 2025 16:10
@yorkie yorkie merged commit 95bbd2e into main Aug 26, 2025
2 checks passed
@yorkie yorkie deleted the copilot/fix-232 branch August 26, 2025 16:11
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.

Implement document.createComment() in client/dom and related files

2 participants