Skip to content

✨ ui: add DOM mutations and events - #40

Open
cowboyd wants to merge 1 commit into
mainfrom
dom-mutation-and-events
Open

cowboyd wants to merge 1 commit into
mainfrom
dom-mutation-and-events

Conversation

@cowboyd

@cowboyd cowboyd commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Add the DOM mutations and event dispatch needed to mount a framework into Clack's terminal document. The operations chosen to implement were those required by Preact 11

  • Add child navigation, insertion, removal, reparenting, and text/attribute updates, with validation and render notifications for connected nodes.
  • Implement event listener registration/removal and capture, target, and bubble dispatch, including cancellation, propagation stops, nested dispatch, and event reuse.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • All tests pass (pnpm test)
  • Files are formatted (pnpm format)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/bombshell-dev/ui/@clack/ui@40

commit: 4ce76a9

@cowboyd
cowboyd added this pull request to stack #42 October 21, 2026 04:36
@cowboyd
cowboyd force-pushed the dom-mutation-and-events branch from 2cc8bab to 70ceefd Compare October 21, 2026 05:08
@socket-security

socket-security Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​changesets/​cli@​2.31.19710010095100

View full report

Comment thread packages/ui/src/dom.ts Resolved
Comment thread packages/ui/src/dom.ts Resolved
Comment thread packages/ui/src/dom.ts Resolved
@cowboyd
cowboyd requested a review from 43081j October 22, 2026 18:29
@cowboyd
cowboyd force-pushed the dom-mutation-and-events branch 5 times, most recently from 450d0bf to c52ab19 Compare October 31, 2026 04:44
@cowboyd
cowboyd force-pushed the dom-mutation-and-events branch from c52ab19 to 4ce76a9 Compare November 2, 2026 16:45
Comment thread packages/ui/src/dom.ts
(this: Target, event: Event): void;
}

export const EventTarget = globalThis.EventTarget;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we re-export these? 👀

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly so that we can pass them in unambiguously to the test suite globals property, and so folks can un-ambiguously import them so there's no confusion about what we're getting. Shall we remove them?

Comment thread packages/ui/src/dom.ts
};
export type Event = globalThis.Event;

export class DOMExecption extends Error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export class DOMExecption extends Error {
export class DOMException extends Error {

Comment thread packages/ui/src/dom.ts

// Node exposes these constants at runtime, but its type declarations omit them.
export const Event = globalThis.Event as typeof globalThis.Event & {
readonly NONE: 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given its about as much code to re-declare these as it is to just have our own constants, what do you think about having our own constants?

i.e. const EVENT_NONE = 0 etc

otherwise i would try solve this through augmentation rather than casting. augment the global interface/class with the extra members etc

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.

3 participants