playcanvas / pcui

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

[BREAKING] Remove `Element#class` setter #272

Closed willeastcott closed 1 year ago

willeastcott commented 1 year ago

The signature for the Element#class setter is:

set class(value: string | string[])

However, the getter has the signature:

get class(): DOMTokenList

This is problematic for TypeScript though:

image

So in the current codebase, the setter leaves the supplied value as an any type.

If the developer wants to set the class(es) on an Element, they should get the class (via the getter) and then simply call the DOMTokenList#add function. As it happens, this is exactly what all (PlayCanvas) PCUI apps do! I can find no instance anywhere where the class setter is called. Therefore, I am taking the opportunity to remove it from the API.