demo · v148

Modern Constructors

Pick an event type. Compare the legacy document.createEvent("X") + initEvent() recipe with the modern constructor (new Event(), new CustomEvent(), new MouseEvent()). Dispatch both and inspect the resulting Event objects.

The removal in Chrome 148 trims document.createEvent()'s accepted name set to what the HTML spec actually requires. Anything off-list throws. The recommended replacement everywhere is the typed constructor — and as a bonus it lets you set detail, bubbles, cancelable, etc. in one init dict.

Legacy — createEvent + initEvent

// pick a type above
Click "Try createEvent" — events land here

Modern — typed constructor

// pick a type above
Click "Try constructor" — events land here

// Run a side to see the resulting Event object inspected here

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗