Skip to content

Instantly share code, notes, and snippets.

@jkempff
jkempff / EventRecorder.js
Created May 11, 2018 16:17
Records DOM-events and replays them on demand. Nice for server side rendered pages: record during page-load, replay after all javascript was initialized.
/**
* EventRecorder
* @class
* @classdesc An EventRecorder can record and replay any event on any DOM node
* @param {string} [eventName=click] - Name of the events to record
* @param {class} [EventClass=MouseEvent] - The class that should be used to recreate the events
* @param {object} [context=self] - The context DOM element, the events should be fetched from
* @example
* // Create a recorder for click events
* const clickRecorder = new EventRecorder('click', MouseEvent, window);