-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allows addEventListener
to use handleEvent
syntax while re-using the object for options
#341
Conversation
…object form for options
Probably |
This is actually an interesting feature to put in. |
Yeah I like the implications of this. Not needing oncapture: etc and allowing full config of native events seems a real win. I might be releasing one more minor of Solid 1.x and I'd like to see this get in. |
@titoBouzout I hope we don't forget to add this to the docs. :) |
@davedbase already on my mind, I will look if typings need updates and how to add tests so gets ready for merging, stay tuned |
… custom events. Move `oncapture` to its own conditional
ok if I am not missing anything I think this is ready for review
Considerations:
should close: Thanks! |
@ryansolid pinging as it was noted the desired to include it on next release |
docs update at solidjs/solid-docs#866 |
…the object for `options` (#341) * allow `addEventListener` to use `handleEvent` syntax while using the object form for options * add type to client.d.ts * add type to lit-dom-expressions/src/index.ts * add to `assignProp` * add to `removeEventListener` on client.js * Update types * Update types * formatting * add `EventHandlerWithOptions` type * use dom-expressions `addEventListener` instead of the browser one for custom events. Move `oncapture` to its own conditional * add test for expected compile output * add test using jsdom to assert a handler with `once` only runs once
This solves in a simple way the common need of wanting to use
passive/once/capture
events.addEventListener
has an "obscure" feature of allowing the listener to be in an object with keyhandleEvent
This PR allows this syntax:
I haven't tested this but it should work https://playground.solidjs.com/anonymous/df01ffcb-e7dc-4a36-b80d-51a398c02689
This is what pota does https://github.com/potahtml/pota/blob/master/src/lib/reactive.js#L1372