Skip to content

Move the event objects to their own module - #88

Closed
brainkim wants to merge 1 commit into
split-modulesfrom
split-events
Closed

Move the event objects to their own module#88
brainkim wants to merge 1 commit into
split-modulesfrom
split-events

Conversation

@brainkim

@brainkim brainkim commented Sep 7, 2026

Copy link
Copy Markdown
Member

Stacked on #87.

src/internal/events.ts (2977 lines out of dom.ts). The Event classes and their init dictionaries, DataTransfer and FileList, EventTarget with its listener store, the event handler attributes, and the integer conversions, construction guard and hover-listener counting they use.

It is a leaf. events.ts has a type-only import from dom.ts and nothing at runtime, so there is no evaluation-order hazard for Node extends EventTarget. Three things made that possible:

  • A target's document is found through the public node and window shape rather than slots.
  • reportError goes through the window's own reportError, which dom.ts implements with a trusted dispatch.
  • dispatchEvent is declared on the class and installed on the prototype by dom.ts, next to the dispatch algorithm, which stays in dom.ts because building the path needs retargeting, slots and activation behavior.

No symbol crosses. The get-the-parent protocol, a symbol-keyed method four tree classes overrode, is one function in dom.ts over the tree types. dom.ts reads dispatch state and listener lists through getDispatchState and getListeners. The 26 prototype installs for the event classes moved with them.

dom.ts goes from 31,416 to 28,522 lines. The lib.dom drift check reads the event classes from the new module.

Typecheck, lint, suite 1619/1619 on node and bun, 37/37 examples, lib.dom drift 148 exact.

🤖 Generated with Claude Code

https://claude.ai/code/session_015Bw3yEu4cfkuDkaZ3RSy4D

The Event classes, DataTransfer, EventTarget with its listener store,
the event handler attributes, and the helpers that go with them leave
dom.ts. events.ts imports nothing from dom.ts at runtime: it finds a
target's document through the public node and window shape, reports
errors through the window's own reportError, and leaves dispatchEvent to
dom.ts, which installs it on the prototype beside the dispatch algorithm
it belongs to. The get-the-parent protocol becomes one function in
dom.ts over the tree types instead of a symbol-keyed method four classes
overrode. dom.ts imports 57 names back, and the drift check reads the
event classes from the new module.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Bw3yEu4cfkuDkaZ3RSy4D
@brainkim

brainkim commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

@claude You have 3 fucking instructions in the CLAUDE.md. Jeez

@brainkim brainkim closed this Sep 7, 2026
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

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.

1 participant