playcanvas / pcui

UI component library for web-based tools
http://playcanvas.github.io/pcui
MIT License
664 stars 62 forks source link

[BREAKING] Remove first parameter of `Element` constructor #273

Closed willeastcott closed 1 year ago

willeastcott commented 1 year ago

At the moment, you can set the DOM element when creating a PCUI Element by setting the first parameter of the Element constructor or by setting the dom property of the ElementArgs options object. The code gives precedence to the first parameter of the constructor, but otherwise, there appears to be little reason why the parameter is needed at all. It makes the constructor signature of Element needlessly different to every other PCUI element class. Therefore, this PR removes it.

As an aside, this PR makes all constructor options objects read-only. The utility type Readonly<...> has been applied to the options object parameter types. For instances where an options objects must to be written to, it is shallow copied to a new object using object destructuring.

Fixes #260