Skip to content
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

Expose event target #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Expose event target #17

wants to merge 2 commits into from

Conversation

tdammers
Copy link

@tdammers tdammers commented Sep 4, 2016

There was already some commented-out code in place to expose the target of an event; I assume it was commented out because the type signature wants target to return a VNode, but it is unclear how to marshal the value back to a VNode. Personally, I believe that return value is wrong, because VNode is a virtual DOM node, but what we get from event.target is an actual DOM node, and the virtual-dom works, virtual → actual is one-way (or that's what I gathered).

Anyway, since marshalling from JS DOM nodes to VNode isn't very useful anyway IMO, I changed things such that the DOM node is just returned as-is, as a JSVal. This is obviously not typesafe, but other than that, it works, and allows me to pull properties out of the event target (in my particular use case, the value, which gets fed back into the reactive event loop on the Haskell side of things).

A proper solution would instead marshal to a properly typed something, but I figured that'd be a future improvement.

ajnsit added a commit to ajnsit/ghcjs-vdom that referenced this pull request Jul 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant