feat(dom): add safe classifiers and missing canvas bindings [Codex] - #362
Conversation
|
I think this is essential, even if it means having some runtime code instead of keeping everything zero-cost. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
f6a3e4b to
83a0ce6
Compare
|
Actually, we should update the DOM examples and also look at other examples that implement bindings or conversion helpers, and add those to the library as well. |
|
Followed up in |
React and DOM APIs often expose broad element types, so consumers and examples otherwise repeat raw
instanceofchecks,Obj.magiccasts, and local property bindings.This adds guarded, polymorphic
classifyhelpers toElement,Document,HTMLElement,HTMLInputElement,HTMLImageElement, andHTMLCanvasElement. Each helper returns an optional concrete interface value, keeps the checked cast inside the binding, and returnsNonewhen the corresponding constructor is unavailable.The test-backed DOM examples now use the public classifiers directly. The canvas example also uses
CanvasRenderingContext2Dbindings forfillStyle,font, andtextBaselineinstead of defining those bindings locally. The generated API comments and DOM guidance explain when narrowing is needed, option handling, unavailable constructors, and the current-realm limitation.Runtime coverage exercises successful classifications, inherited interface matches, mismatches, and missing global constructors. No dependencies are added.