Closed bert-mccutchen closed 4 years ago
The serializeEventDetails function attempts to perform destructuring assignment on event objects: https://github.com/unabridged/motion/blob/7464c9955d803af1dbb9062dc71028704d93b335/javascript/serializeEvent.js#L28
serializeEventDetails
However, object destructuring ends up using hasOwnProperty when transpiled, as can be seen here:
hasOwnProperty
function serializeEventDetails(event) { var details = {}; var _iterator = _createForOfIteratorHelper(detailProperties), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var property = _step.value; if (Object.prototype.hasOwnProperty.call(event, property)) { details[property] = event[property]; } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return details; }
This is an issue since hasOwnProperty will always return false on Event objects. See this StackOverflow for more details
false
const { key } = new KeyboardEvent('keydown', { key: 'test' }) key // => 'test' new KeyboardEvent('keydown', { key: 'test' }).hasOwnProperty('key') // => false
I came across this while using keyboard events, it is not limited to only keyboard events.
@bert-mccutchen this is such a thorough and detailed bug report, thanks so much for reporting this!
The
serializeEventDetails
function attempts to perform destructuring assignment on event objects: https://github.com/unabridged/motion/blob/7464c9955d803af1dbb9062dc71028704d93b335/javascript/serializeEvent.js#L28However, object destructuring ends up using
hasOwnProperty
when transpiled, as can be seen here:This is an issue since
hasOwnProperty
will always returnfalse
on Event objects. See this StackOverflow for more detailsI came across this while using keyboard events, it is not limited to only keyboard events.