This would work nicely with static HTML, indeed. But once you have some JavaScript i.e. dynamic HTML, it won't work reliably anymore. Worse, it might even give you a list of manually curated CSS properties to "allow list".
I'd forgotten about it and am now wondering if anyone made a replacement...
the only thing that does not work is generating the css class like:
var x = 'hase-';
var t = x + 'danger'
which is an antipattern. (it can even happen inside java, c#, whatever language you use and it is still an antipattern)
switch(buttonColor) {
'red': return 'button-red';
'blue': return 'button-blue';
}
over return 'button-' + buttonColor;