rescript-webapi icon indicating copy to clipboard operation
rescript-webapi copied to clipboard

HtmlElement.ofNode doesn't do any type html element specific checking

Open spocke opened this issue 3 years ago • 1 comments

The HtmlElement.ofNode function is just inherited from Element so it allows you to pass in Elements and get them converted to HtmlElements without any check so it's not really type safe.

So this will set the non existing contentEditable property on plain elements. node->HtmlElement.ofNode->Belt.Option.forEach(HtmlElement.setContentEditable(True))

spocke avatar Dec 28 '21 06:12 spocke

oh hmm I forgot we had both ofElement and ofNode. I think we might need to remove ofNode from the inheritance chain; it's only correct for elements not most places Element is included.

Either that or override it in HtmlElement to just use the ofElement implementation which should work for both elements and nodes.

TheSpyder avatar Dec 28 '21 22:12 TheSpyder