jsx-dom icon indicating copy to clipboard operation
jsx-dom copied to clipboard

RFC Support capture events, fix custom events, support on/onCapture

Open KapitanOczywisty opened this issue 2 years ago • 2 comments

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.

KapitanOczywisty avatar Sep 25 '21 21:09 KapitanOczywisty

why not use key.startsWith('on') ?

adminy avatar Oct 03 '21 13:10 adminy

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.

KapitanOczywisty avatar Oct 03 '21 14:10 KapitanOczywisty

Is this PR likely to be merged anytime soon?

DojoEnglish avatar Sep 21 '22 13:09 DojoEnglish

@DojoEnglish No, do you have a use case for this?

alex-kinokon avatar Sep 22 '22 03:09 alex-kinokon

@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.

KapitanOczywisty avatar Sep 22 '22 07:09 KapitanOczywisty

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

DojoEnglish avatar Sep 22 '22 07:09 DojoEnglish