Basic Events

setEvents() provides a chainable API for attaching native DOM event listeners.

Existing handlers are automatically replaced to avoid duplicated listeners during repeated mutations.

Important

DOMPP attaches native DOM events directly.

No synthetic event system, delegation runtime, or virtual DOM layer is involved.

Reapplying the same event automatically replaces the previous listener to keep event mutation predictable.

Code

const result =
  document
    .createElement("p")
    .setText(
      "Waiting for interaction..."
    );

const button =
  document
    .createElement("button")
    .setText(
      "Click Me"
    )
    .setEvents({
      click() {
        result.setText(
          "Button clicked."
        );
      }
    });
    
const card =
  document
    .createElement("div")
    .setAttributes({
      class: "card"
    })
    .setChildren(
      button,
      result
    );

app.setChildren(
  card
);
Notes
  • setEvents() works with native browser events directly
  • previous listeners are replaced automatically during mutation
  • event handlers remain attached to the same native DOM element

Live Preview