Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Classify for Dom.node #178

Open
Risto-Stevcev opened this issue May 5, 2020 · 4 comments
Open

Classify for Dom.node #178

Risto-Stevcev opened this issue May 5, 2020 · 4 comments

Comments

@Risto-Stevcev
Copy link
Member

Something like Js.Json.classify and Js.Types.classify but for Dom.nodes

It would be based on similar tags as
https://github.com/reasonml-community/bs-webapi-incubator/blob/master/src/Webapi/Webapi__Dom/Webapi__Dom__Types.re#L177-L190

But parameterized, ie:

type t =
  | Element of Dom.element
  | Text of Dom.text
  ...

let classify (node: Dom.node) : t = ...
@glennsl
Copy link
Member

glennsl commented May 6, 2020

Not sure if you're asking for my approval of this, but if you are: I approve!

@Risto-Stevcev
Copy link
Member Author

Yeah, but also just adding it here so I don't forget about it. I'm not sure when I'd be able to work on this

@yawaramin
Copy link
Collaborator

@Risto-Stevcev if you are planning to use instanceof, note that it's tricky because different windows have different prototype chains and instanceof doesn't work across windows. This will need to be accounted for. See e.g.

let asHtmlElement: T.t => option(Dom.htmlElement) = [%raw {|

@Risto-Stevcev
Copy link
Member Author

Thanks for the heads up @yawaramin 🙂

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

No branches or pull requests

3 participants