0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-15 03:28:25 -05:00
penpot/frontend/text-editor/editor/Event.js
2024-11-19 17:05:30 +01:00

32 lines
867 B
JavaScript

/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) KALEIDOS INC
*/
/**
* Adds a series of listeners.
*
* @param {EventTarget} target
* @param {Object.<string, Function>} object
* @param {EventListenerOptions} [options]
*/
export function addEventListeners(target, object, options) {
Object.entries(object).forEach(([type, listener]) =>
target.addEventListener(type, listener, options)
);
}
/**
* Removes a series of listeners.
*
* @param {EventTarget} target
* @param {Object.<string, Function>} object
*/
export function removeEventListeners(target, object) {
Object.entries(object).forEach(([type, listener]) =>
target.removeEventListener(type, listener)
);
}