When creating events, you should use the right constructor. For example new MouseEvent('click')
instead of a plain new Event('click')
.
As far as I know there's no way to this automatically so there could be DOM event creator that includes such map.
import createEvent from 'β¨';
document.body.dispatchEvent(createEvent('keydown', {key: 'a'}))
This particularly useful when your app can trigger a variety of events and you can't be bothered to match them manually π
import createEvent from 'β¨';
const eventsToDispatch = ['mousedown', 'pointerdown', 'click', 'mouseup', 'pointerup']
for (const eventName of eventsToDispatch)
document.body.dispatchEvent(createEvent(eventName))
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too