Skip to content

feat(dom): add safe classifiers and missing canvas bindings [Codex] - #362

Merged
jderochervlk merged 3 commits into
mainfrom
feature/dom-classify
Sep 18, 2026
Merged

jderochervlk merged 3 commits into
mainfrom
feature/dom-classify

Conversation

@jderochervlk

@jderochervlk jderochervlk commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

React and DOM APIs often expose broad element types, so consumers and examples otherwise repeat raw instanceof checks, Obj.magic casts, and local property bindings.

This adds guarded, polymorphic classify helpers to Element, Document, HTMLElement, HTMLInputElement, HTMLImageElement, and HTMLCanvasElement. Each helper returns an optional concrete interface value, keeps the checked cast inside the binding, and returns None when the corresponding constructor is unavailable.

The test-backed DOM examples now use the public classifiers directly. The canvas example also uses CanvasRenderingContext2D bindings for fillStyle, font, and textBaseline instead 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.

@Freddy03h

Copy link
Copy Markdown
Collaborator

I think this is essential, even if it means having some runtime code instead of keeping everything zero-cost.

@jderochervlk
jderochervlk marked this pull request as ready for review September 18, 2026 13:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-18T14:01:02.026206Z 670bba7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jderochervlk
jderochervlk changed the base branch from vlk/base to main September 18, 2026 13:03
@jderochervlk
jderochervlk marked this pull request as draft September 18, 2026 13:04
@jderochervlk
jderochervlk marked this pull request as ready for review September 18, 2026 13:11
@Freddy03h

Copy link
Copy Markdown
Collaborator

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.

@jderochervlk jderochervlk changed the title feat(dom): add safe element classifiers [Codex] feat(dom): add safe classifiers and missing canvas bindings [Codex] Sep 18, 2026
@jderochervlk

Copy link
Copy Markdown
Collaborator Author

Followed up in 670bba7: the input and canvas examples now use public classifiers, HTMLCanvasElement and HTMLImageElement have guarded classifiers, and the canvas property helpers live in CanvasRenderingContext2D. I also audited the other examples; the remaining local externals and Obj.magic values are test fixtures rather than reusable binding gaps. Verified with npm test, npm run format:check, all 27 feature builds, and the full docs build.

@jderochervlk
jderochervlk merged commit 9ce266c into main Sep 18, 2026
3 checks passed
@jderochervlk
jderochervlk deleted the feature/dom-classify branch September 18, 2026 14:03
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.

4 participants