Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Add HTMLHyperlinkElementUtils #143

Open
chexxor opened this issue Feb 17, 2018 · 1 comment
Open

Add HTMLHyperlinkElementUtils #143

chexxor opened this issue Feb 17, 2018 · 1 comment

Comments

@chexxor
Copy link
Contributor

chexxor commented Feb 17, 2018

The a and area elements implement the HTMLHyperlinkElementUtils interface [0]. How are mixin interfaces like this usually included in this repo? It's not a proper element, just an extracted interface, so we can't make a new type in DOM.HTML.Types and check the tag name like this:

-- We can't do this, because an `a` element returns tag name of "HTMLAnchorElement".
readHTMLHyperlinkElementUtils :: Foreign -> F HTMLHyperlinkElementUtils
readHTMLHyperlinkElementUtils = unsafeReadTagged "HTMLHyperlinkElementUtils

But we could do this:

htmlAnchorElementToHTMLHyperlinkElementUtils :: HTMLAnchorElement -> HTMLHyperlinkElementUtils
htmlAnchorElementToHTMLHyperlinkElementUtils = unsafeCoerce

and put that interface's members in a DOM.HTML.HTMLHyperlinkElementUtils module, like the href function. Should we just do that?

[0] https://html.spec.whatwg.org/multipage/links.html#htmlhyperlinkelementutils

@garyb
Copy link
Member

garyb commented Feb 18, 2018

Yep, unsafeCoerce is fine here - it's not an upcast, so it won't fail, and since it's an interface there's no corresponding class we can unsafeReadTagged for.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants