Current behavior
If, when using the .on function, the event type equals any of the properties of Object.prototype (in particular, constructor, hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, toString, valueOf), a JavaScript native TypeError is thrown by the framework.
This is because of how eventsFocus and eventsHover are defined and used. The getEventNameBubbling function returns eventsHover[name] if this is not a falsey value. However, when name === "valueOf", for example, this property is found in Object.prototype and the corresponding function object is returned. Later, a .split will be invoked on that object, assuming incorrectly that it is a string, resulting in the error.
This is a common error when using objects as maps in JavaScript, and TypeScript types are not strong enough to catch it.
Expected behavior
No TypeError should be thrown, eventsFocus[name] and eventsHover[name] should return undefined, and the execution should continue.
Solution
Create eventsFocus and eventsHover using Object.create(null) to disable any prototype inheritance.
Current behavior
If, when using the
.onfunction, the event type equals any of the properties ofObject.prototype(in particular,constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf), a JavaScript native TypeError is thrown by the framework.This is because of how
eventsFocusandeventsHoverare defined and used. ThegetEventNameBubblingfunction returnseventsHover[name]if this is not a falsey value. However, whenname === "valueOf", for example, this property is found inObject.prototypeand the corresponding function object is returned. Later, a.splitwill be invoked on that object, assuming incorrectly that it is a string, resulting in the error.This is a common error when using objects as maps in JavaScript, and TypeScript types are not strong enough to catch it.
Expected behavior
No TypeError should be thrown,
eventsFocus[name]andeventsHover[name]should returnundefined, and the execution should continue.Solution
Create
eventsFocusandeventsHoverusingObject.create(null)to disable any prototype inheritance.