Closed rmorshea closed 5 years ago
@gnestor thoughts?
This has been specified in https://github.com/nteract/vdom/blob/master/docs/event-spec.md. You can see it in action in the curren @nteract/transform-vdom implementation: https://github.com/nteract/nteract/blob/master/packages/transform-vdom/src/event-to-object.ts#L17.
@gnestor it seems like you special cased grabbing target.value
for the "submit" event in vdom-transform
, however there might be more cases in which you might want to grab an arbitrary property on the target, or grab target.value
on other events (e.g. onKeyDown
).
Totally. This event spec was based largely on React's SyntheticEvent spec. If it doesn't cover an obvious use case, then we can modify it.
Summary
In my own front end implementation I found that it would be tedious to determine how to serialize every possible event.
Instead of doing this you could define the exact attributes of the event object that need to be sent back to the handler. The new spec for event handlers might look something like this:
Consider one possible API that could leverage this:
The serialized event handler might then looks like this:
Special Case
If you are defining a callback for an "input" element you may want to know the current value contained in the input. At the moment there is no way to do this. However, you could leverage this new event handler design to specify a path to an attribute:
We could capture the name of the pressed key and the current input value with the following spec: