Closed IrregularShed closed 7 years ago
@IrregularShed good catch - are you specifying the custom class via className
in your JSX? We might be able to change how preact-mdl looks for class
, it's probably not accounting for className
being there. A long time ago, Preact used to normalize className
to class
for Components, but this proved troublesome so it no longer does. Likely preact-mdl
predates that change and needs to do a little extra work to check both properties itself.
Fix released as preact-mdl@2.1.0
!
Excellent work sir!
I've been scratching my head about this for the best part of a day, but have found the origin - I'm not sure whether the issue belongs to
preact-compat
orpreact-mdl
though.If you are using preact-compat and assign a custom class/className to a component, all the MDL classes are removed. Singlestepping through the code I found that the class I assigned was added to both
class
andclassName
attributes in the VNode (while all the MDL classes were just in theclass
attribute) and when the component was finally rendered only the classes listed inclassName
actually made it onto the DOM nodes.The workaround is to not use
preact-compat
, so that there's no conflict between theclass
andclassName
attributes. Obviously not ideal in all cases, although the amount of changes required aren't massive and chances are if you're usingpreact-mdl
you've bought into the ecosystem enough to start removing the compatibility layer.