Skip to content

Get a canvas element without resorting to an HTML id #91

Open
@glocq

Description

@glocq

It is my understanding that the only way to produce a value with type CanvasElement is to use getCanvasElementById. This forces use of an HTML id, but there are ways to access HTML elements without them having an id (i.e. with getHTMLElementRef in Halogen, for instance).

It would be nice to have a function fromElement :: HTMLElement -> Maybe CanvasElement (or HTMLElement -> Maybe CanvasElement).*

Doing away with the need for HTML IDs reduces the risk of collision between e.g. canvases from two instances of the same Halogen component.

* HTMLElement is defined here: https://pursuit.purescript.org/packages/purescript-web-html/4.1.0/docs/Web.HTML.HTMLElement#t:HTMLElement
Element is defined here: https://pursuit.purescript.org/packages/purescript-web-dom/6.0.0/docs/Web.DOM.Internal.Types#t:Element

Metadata

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