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

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

Open
glocq opened this issue Mar 18, 2024 · 0 comments
Open

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

glocq opened this issue Mar 18, 2024 · 0 comments

Comments

@glocq
Copy link

glocq commented Mar 18, 2024

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

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

No branches or pull requests

1 participant