Is there any way to prevent compose web from overwriting classes added externally?
E.g. Ionic framework automatically adds classes like "hydrated" to certain elements. But Compose web erases them when re-composing
b
Big Chungus
11/04/2021, 4:52 PM
You might be able to merge them via DomSideEffect which gives you access to native element
a
Akif Abasov [JB]
11/05/2021, 7:57 AM
It’s not allowed to mutate outside dom attributes which are controlled by compose, because there could be such conflicts.
b
Big Chungus
11/05/2021, 8:12 AM
I meant controlling all classes via DomSideEffect with proper keys. That way compose is oblivious of any classes
b
Brian G
11/05/2021, 10:11 AM
I understand why it was built that way, but in the real world, many existing JS libraries like to mess with classes & attributes.
It's technically possible for Compose Web to be less destructive (e.g. don't remove a class that Compose itself didn't add) which would increase compatibility with existing libraries.
Brian G
11/05/2021, 10:12 AM
My workaround is that I've removed any state observation from the attr-builder lambda, so that it essentially never re-runs (so it never erases the externally-added classes). Still has me nervous about it though.