-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: remove non-standard APIs #1
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
Conversation
Summary of ChangesHello @xusd320, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on refining the API surface of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request effectively refactors the API to align more closely with standard DOM APIs by removing non-standard methods and favoring property-based access (e.g., innerHTML instead of innerHtml()). The changes are consistent across the Rust implementation and the corresponding TypeScript definitions. I've identified a minor issue in the TypeScript definition files where a method is declared twice, which I've commented on. Overall, this is a solid improvement for API consistency and usability.
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 pull request removes non-standard API methods from the Node.js bindings, standardizing the API surface to match standard DOM APIs. The changes primarily involve removing the #[napi] attribute from several internal Rust methods and cleaning up JavaScript exports.
Key Changes:
- Removed non-standard methods (
select,selectAll,getChildren,getAttributes,clone,cloneRecursive,outerHtml,innerHtml,text) from the public API while keeping standard DOM equivalents (querySelector,querySelectorAll,cloneNode) - Removed
parsefunction export fromdomparser.jswhile keeping it available throughDOMParser.parseFromString - Updated TypeScript definitions to reflect the new API surface
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| index.d.ts | Removed type declarations for non-standard methods that are no longer exposed to JavaScript |
| domparser.js | Removed parse from module exports (still available internally for DOMParser.parseFromString) |
| crates/domparser_napi/src/node_repr/query.rs | Removed #[napi] attributes from select, select_all, outer_html, inner_html, and text methods; deleted get_children and get_attributes methods entirely |
| crates/domparser_napi/src/node_repr/mod.rs | Removed #[napi] attributes from clone_self_only and clone_recursive methods (still used internally by cloneNode) |
| crates/domparser_napi/index.d.ts | Removed type declarations matching the changes in the root index.d.ts (auto-generated file) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kuitos
left a comment
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.
LGTM
fa00806 to
e4a1265
Compare
This pull request makes several improvements and cleanups to the DOM parser's Rust and JavaScript bindings. The main changes include refining attribute handling in Rust, removing some unnecessary JavaScript exports, and updating the expected version for native bindings in the Node.js loader. Additionally, several N-API annotations have been removed from Rust methods, likely to streamline or refactor the JS interface.
Rust binding improvements and cleanup:
get_attributemethod inNodeReprto better handle attribute lookup, including a fallback to search by qualified name, and updated the logic for retrieving attribute names to include namespace prefixes when present. [1] [2]get_childrenandget_attributesmethods fromNodeRepr, streamlining the Rust API.#[napi]and#[napi(js_name = ...)]annotations from several Rust methods, possibly as part of a refactor to manage the JS interface differently. [1] [2] [3] [4] [5] [6]JavaScript/Node.js binding updates:
0.0.0to0.0.1in the version check logic ofindex.js, ensuring compatibility with the new native release. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]parsefunction fromdomparser.js, likely to simplify the public API.These changes collectively improve the maintainability and correctness of the bindings, and align the JS and Rust interfaces more closely.