Constructors don't work for DOM elements
ghik opened this issue · 4 comments
ghik commented
I don't see a reason why DOM elements like HTMLElement
are represented by classes and not traits or abstract classes.
Currently the compiler does not protect us from trying to create HTML elements with plain constructor but it won't work in runtime.
sjrd commented
Those for which creation at runtime is not permitted by the spec should indeed be abstract classes.
mseddon commented
Any reason to use abstract class
over trait
? We tend to use trait
in things like AudioAPI, WebGL, etc., so it would be more consistent if possible to use trait, I'd say.
sjrd commented
Yes, you can do x.isInstanceOf[dom.HTMLElement]
if HTMLElement
is a class. It translates to x instanceof HTMLElement
in JS. You can't do that if it's a trait.
mseddon commented
Gotcha, okay, I'll go with that, then.