bs-webapi-incubator icon indicating copy to clipboard operation
bs-webapi-incubator copied to clipboard

Classify for Dom.node

Open Risto-Stevcev opened this issue 4 years ago • 4 comments

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 = ...

Risto-Stevcev avatar May 05 '20 20:05 Risto-Stevcev

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

glennsl avatar May 06 '20 19:05 glennsl

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

Risto-Stevcev avatar May 08 '20 14:05 Risto-Stevcev

@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. https://github.com/reasonml-community/bs-webapi-incubator/blob/aad089aa2cd93e8884f53afb2507c2321265ff46/src/Webapi/Webapi__Dom/Webapi__Dom__Element.re#L8

yawaramin avatar Jul 05 '20 23:07 yawaramin

Thanks for the heads up @yawaramin 🙂

Risto-Stevcev avatar Jul 08 '20 08:07 Risto-Stevcev