Skip to content

Commit

Permalink
fix: Remove Firefox warnings about deprecated event props (#8736)
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben authored May 30, 2024
1 parent 42e167c commit 084af2f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/js/utils/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 084af2f

Please sign in to comment.