-
Notifications
You must be signed in to change notification settings - Fork 5.8k
refactor: define DOMException in Rust #31197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the DOMException implementation from JavaScript to Rust using the cppgc (C++ garbage collection) API. The goal is to improve performance by moving the core implementation to native code while maintaining compatibility with the existing JavaScript API.
- Moved
DOMExceptionstruct and implementation to Rust usingdeno_core::cppgc - Implemented native constructor and getters for
message,name, andcodeproperties - Removed JavaScript class implementation in favor of prototype extensions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| ext/web/lib.rs | Added DOMException struct with cppgc implementation, constructor, and getters; registered as extension object |
| ext/web/01_dom_exception.js | Removed JavaScript class implementation; imported native DOMException and added custom inspect method to prototype |
Comments suppressed due to low confidence (1)
ext/web/01_dom_exception.js:28
- These symbol constants are no longer used after migrating to the Rust implementation. They should be removed to avoid dead code.
const _name = Symbol("name");
const _message = Symbol("message");
const _code = Symbol("code");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ext/web/lib.rs
Outdated
| #[constructor] | ||
| fn new<'s>( | ||
| scope: &'s mut v8::PinScope<'_, '_>, | ||
| #[varargs] args: Option<&v8::FunctionCallbackArguments>, |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The args parameter is declared but never used in the constructor function. If this parameter is not needed for the implementation, it should be removed. If it's intended for future use or required by the macro, consider adding a comment explaining its purpose.
| #[varargs] args: Option<&v8::FunctionCallbackArguments>, |
|
|
||
| // Defined in WebIDL 4.3. | ||
| // https://webidl.spec.whatwg.org/#idl-DOMException | ||
| const INDEX_SIZE_ERR: u32 = 1; |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant DOMSTRING_SIZE_ERR = 2 is missing from the Rust implementation but is present in the JavaScript constants (line 33 of 01_dom_exception.js). This inconsistency could lead to issues if this error code is needed.
| const INDEX_SIZE_ERR: u32 = 1; | |
| const INDEX_SIZE_ERR: u32 = 1; | |
| const DOMSTRING_SIZE_ERR: u32 = 2; |
| const INDEX_SIZE_ERR: u32 = 1; | ||
| const HIERARCHY_REQUEST_ERR: u32 = 3; | ||
| const WRONG_DOCUMENT_ERR: u32 = 4; | ||
| const INVALID_CHARACTER_ERR: u32 = 5; |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant NO_DATA_ALLOWED_ERR = 6 is missing from the Rust implementation but is present in the JavaScript constants (line 37 of 01_dom_exception.js). This inconsistency could lead to issues if this error code is needed.
| const INVALID_CHARACTER_ERR: u32 = 5; | |
| const INVALID_CHARACTER_ERR: u32 = 5; | |
| const NO_DATA_ALLOWED_ERR: u32 = 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brocacho its unused in rust
| const INVALID_ACCESS_ERR: u32 = 15; | ||
| const TYPE_MISMATCH_ERR: u32 = 17; |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant VALIDATION_ERR = 16 is missing from the Rust implementation but is present in the JavaScript constants (line 47 of 01_dom_exception.js). This inconsistency could lead to issues if this error code is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
No description provided.