From f92eb2375ef010dada07e65ee8fc6cde2d089dca Mon Sep 17 00:00:00 2001 From: mister-ben Date: Fri, 17 May 2024 17:05:49 +0200 Subject: [PATCH] fix: Remove Firefox warnings about deprecated event props --- src/js/utils/events.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/js/utils/events.js b/src/js/utils/events.js index 6527dc8e7a..2a76b07083 100644 --- a/src/js/utils/events.js +++ b/src/js/utils/events.js @@ -112,15 +112,19 @@ export function fixEvent(event) { // IE8 Doesn't like when you mess with native event properties // Firefox returns false for event.hasOwnProperty('type') and other props // which makes copying more difficult. - // TODO: Probably best to create a whitelist of event props + + // TODO: Probably best to create an allowlist of event props + const deprecatedProps = [ + 'layerX', 'layerY', 'keyLocation', 'path', + 'webkitMovementX', 'webkitMovementY', 'mozPressure', 'mozInputSource' + ]; + for (const key in old) { // Safari 6.0.3 warns you if you try to copy deprecated layerX/Y // Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation // and webkitMovementX/Y // Lighthouse complains if Event.path is copied - if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation' && - key !== 'webkitMovementX' && key !== 'webkitMovementY' && - key !== 'path') { + if (!deprecatedProps.includes(key)) { // Chrome 32+ warns if you try to copy deprecated returnValue, but // we still want to if preventDefault isn't supported (IE8). if (!(key === 'returnValue' && old.preventDefault)) {