Closed paranoidjk closed 5 years ago
cc @developit
What if we made it non-enumerable?
@developit It probably ok. Since we normally won't access props.class
directly in react codebase, and babel will compile spread operator to use Object.assign
or a polyfill with for in
, in this case it should works fine .
But i am not sure it will be 100% safe. So i think there is a tradeoff.
IMO, i suggest preact-compat avoid to pollute users component props object in runtime, it's a little dangerous.
I'm unable to reproduce the described issue with Preact X anymore :tada:
Reproducible demo: https://codepen.io/paranoidjk/pen/MvdLpd
This is caused by https://github.com/developit/preact-compat/pull/412, it breaks our code base, please revert it.
The reason is preact-compat add a extra alias attribute
class
to component props when it hasclassName
attribute.But in some case, we will want to omit
className
and pass rest props to child component, in this case, child component will got a unexpected class attribute.I think preact-compat can not require users to delete
class
andfor
when they want to omitclassName
,htmlFor
, sincepreact-compat
goal is to compatibility with react but no need to change users code when they want to switch form react to preact.