Skip to content

feat: expose element creation context to tree adapters - #1842

Merged
43081j merged 1 commit into
inikulin:masterfrom
domenic:codex/element-creation-hook
Sep 14, 2026
Merged

43081j merged 1 commit into
inikulin:masterfrom
domenic:codex/element-creation-hook

Conversation

@domenic

@domenic domenic commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Add an optional onElementCreated tree-adapter callback that runs after element creation and before insertion, exposing the intended parent, form element pointer, and template-stack state. jsdom needs these parser-only values to implement step 15 of “create an element for the token”, which establishes parser-created form owners, without subclassing the internal Parser class.

The parser computes each insertion location once so the callback context and subsequent insertion use the same target.

Comment thread packages/parse5/lib/parser/index.ts Outdated
Expose the intended parent, form element pointer, and template-stack state after a tree adapter creates an element and before the parser inserts it. DOM-backed adapters need this state to establish parser-created form owners as required by the HTML parser.

Compute each insertion location once so the callback context and the subsequent insertion use the same target.

Co-authored-by: codex <codex@openai.com>
@domenic
domenic force-pushed the codex/element-creation-hook branch from 68482df to fbd6408 Compare September 2, 2026 09:28
@domenic

domenic commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Gentle ping! I would love to improve jsdom's form-association machinery based on this.

@43081j

43081j commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

This looks good, I'm just away this week at ZurichJS.

I'll give it another review when I'm back and aim to merge 👍

@43081j
43081j merged commit a7f1f24 into inikulin:master Sep 14, 2026
7 checks passed
@domenic
domenic deleted the codex/element-creation-hook branch September 15, 2026 06:46
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.

2 participants