jsx-dom
jsx-dom copied to clipboard
RFC Support capture events, fix custom events, support on/onCapture
Support capture events
Events like onClickCapture
are present in typings, but weren't working. PR add support for Capture variants.
Fix custom events
Currently custom events are not working, seems like if
was improperly copied in #38
https://github.com/proteriax/jsx-dom/blob/35d58db68c783d3ab2f7a84abec90bc5f22a92a6/src/jsx-dom.ts#L298-L306
This PR brings back addEventListener
. If it'd working properly before, this would also introduce breaking change - now events are registered as lowercase and without on, but custom events were not working anyway (onCustomEvent
was assigned to element.oncustomevent
instead of calling addEventListener
).
Support on
/onCapture
To properly support custom event I'm proposing 2 new properties on
and onCapture
. Every key is added as-is, so user have full control of event name. Standard events are supported in lowercase form - as expected. These are always registered using addEventListener
- this is good compromise for people who don't want to use element.onclick
properties. onClick
handlers are left for people like OP from #17 . Also this should fully satisfy #33
Look at tests for examples.
why not use key.startsWith('on')
?
why not use
key.startsWith('on')
?
@adminy This was already present in code, but my guess is performance optimization or compatibility or no reason at all.
Is this PR likely to be merged anytime soon?
@DojoEnglish No, do you have a use case for this?
@alex-kinokon nice to hear after a year that there is a problem with PR.
@DojoEnglish I'm using patch-package to fix issues, which are ignored by author.
Same reason as the initial comments for this PR, I'm looking to support custom events, as a workaround for now I've had to manually add an event listener