Skip to content

A way to access form element values #10

Open
@eamsden

Description

There is presently no way to access the value of a form element in ghcjs-vdom.

Some ideas considered:

Bundle the value with the change event

This is promising but requires some work to ensure that the value accessor on the event type is referentially transparent. I.e. if a second change event were to fire and the accessor were then called on the Event value handed to the callback the first time, the accessor would return the new value, unless some caching were implemented.

In addition, this requires users of ghcjs-vdom to save the values from change events so that the value can be accessed when desired

Use a Hook to get access to the actual DOM element

virtual-dom allows VNodes to contain Hooks, which are callbacks that are called with the actual DOM element when the VNode is rendered. The main issue with this approach is the question of how to tie a reference to this element back into a change event handler. The change event handler must be attached to the VNode prior to rendering (and a VNode may appear multiple places in the virtual DOM and thus produce multiple elements when patched) while the Hook does not run until patch time. Some form of wormholing (e.g. setting up an IORef where the DOM element will be used and writing to it in the hook) will probably be necessary.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions