-
Notifications
You must be signed in to change notification settings - Fork 3
Add HTMLInputElement support to JSAR runtime #148
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
Add HTMLInputElement support to JSAR runtime #148
Conversation
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
yorkie
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.
You should implement HTMLInputElement in C/C++ including js binding, native dom class, layout class and render at web content renderer
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Implemented HTMLInputElement natively in C++ as requested! The complete implementation includes: Native DOM Class: All components work together - HTMLInputElement is now properly registered in TYPED_ELEMENT_MAP and available globally as expected by the C++ code. The previous TypeScript polyfill has been removed. Commit: abf75bf |
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
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 implements HTMLInputElement support for the JSAR spatial web runtime, which was previously referenced in C++ code but not fully implemented. The implementation adds comprehensive form control functionality including various input types, validation, and proper DOM integration.
- Complete HTMLInputElement class implementation with all standard properties and methods
- C++ DOM implementation with proper layout handling and JavaScript bindings
- Browser compatibility data updated to reflect new HTMLInputElement support
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/client/layout/layout_view.cpp | Adds factory support for creating LayoutHTMLInput objects |
| src/client/layout/layout_object.hpp | Adds virtual isInput() method to base layout object class |
| src/client/layout/layout_html_input.hpp | Defines LayoutHTMLInput class for handling input element layout |
| src/client/layout/layout_html_input.cpp | Implements basic layout lifecycle methods for input elements |
| src/client/html/html_input_element.hpp | Declares HTMLInputElement class with comprehensive input functionality |
| src/client/html/html_input_element.cpp | Implements all HTMLInputElement methods including validation and styling |
| src/client/html/all_html_elements.hpp | Includes HTMLInputElement in the collection of all HTML elements |
| src/client/dom/element.hpp | Adds input element to factory macro and updates getAttribute signature |
| src/client/dom/element.cpp | Implements getAttribute with default value parameter |
| src/bindings/dom/html_input_element.hpp | Declares JavaScript bindings for HTMLInputElement |
| src/bindings/dom/html_input_element.cpp | Implements all JavaScript property getters/setters and methods |
| src/bindings/dom/element.hpp | Adds null check in ElementBase constructor |
| src/bindings/dom/all_html_elements.hpp | Includes HTMLInputElement bindings |
| fixtures/html/htmlinputelement-test.html | Provides comprehensive test fixture for HTMLInputElement functionality |
| docs/api/browser-compat-data/html/elements/input.json | Updates compatibility data to show HTMLInputElement support |
| double value = node->valueAsNumber(); | ||
| if (std::isnan(value)) | ||
| { | ||
| return env.Null(); |
Copilot
AI
Aug 1, 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.
Returning null for NaN values in valueAsNumber getter deviates from the HTML standard, which should return NaN as a number value, not null.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR implements HTMLInputElement support for the JSAR spatial web runtime, addressing the missing form control functionality that was referenced in the C++ code but not implemented.
Problem
The JSAR runtime C++ code expected
HTMLInputElementto be available globally (referenced insrc/client/dom/dom_scripting.cpp:359), but the DOM implementation was missing this crucial HTML element. This caused issues when loading HTML documents containing<input>elements, which are used in several existing fixtures likeparsing-void-tags.htmlandunquoted-attributes-demo.html.The browser compatibility data also showed
HTMLInputElementsupport asversion_added: false, indicating this was a known missing feature.Solution
Implemented a comprehensive HTMLInputElement class that provides:
Core Features
type,value,checked,required,disabled,placeholder, etc.checkValidity(),setCustomValidity(),reportValidity()with proper validity state managementselect(),setSelectionRange()for text-based inputsstepUp(),stepDown()for numeric input typesonchange,oninput,onblur,onfocusImplementation Details
lib/dom/HTMLInputElement.tswith full HTMLInputElement interface implementationlib/polyfills.tsto makeHTMLInputElementconstructor available as expected by C++ codeExample Usage
HTML Support
Testing
<input>elements can now be properly processedThis implementation provides a solid foundation for form controls in the JSAR spatial web environment and resolves the missing HTMLInputElement support that was preventing proper handling of HTML input elements.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
registry.npmmirror.comnpm install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.