-
Notifications
You must be signed in to change notification settings - Fork 653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix adding undefined to class #504
Fix adding undefined to class #504
Conversation
this.appliedClasses[type][phase] = className | ||
addClass(node, className) | ||
if (className) { | ||
this.appliedClasses[type][phase] = className |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be outside the conditional, no? we want to e.g. reset old values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@taion I think that it is unnecessary to add falsy value to object and run addClass function, i can remove this conditional if you think that it will be better approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, we want to clear any previous value that was there, no? e.g. if this already ran a transition, and the class mappings are dynamic, then we don't want to keep around an old stale value from the last time the transition ran?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
className will be undefined for this case (when doneClassName is undefined), so if it is undefined we could pass through:
this.appliedClasses[type][phase] = className
appliedClasses is used in removeClasses function, and it also check for undefined
also we can pass through:
addClass(node, className)
cause it check if className is falsy.
So I suppose it is equivalent, but with this condition, we can skip addClass and pass undefined value to appliedClasses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess we wipe it in
react-transition-group/src/CSSTransition.js
Line 193 in 5e2c1c4
this.appliedClasses[type] = {}; |
src/CSSTransition.js
Outdated
@@ -198,6 +201,10 @@ class CSSTransition extends React.Component { | |||
if (doneClassName) { | |||
removeClass(node, doneClassName); | |||
} | |||
// Remove class atribute if it is empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this change? this seems like essentially a separate thing. does it hurt to leave an empty class
attribute around? we wouldn't know if e.g. the node originally had a class=""
, would we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@taion youp. I don't know if it is right approach. I add it to cleanup for this specific case, cause it just add class to div, like so:
<div class></div>
<div class></div>
<div class></div>
Maybe there is another way to fix this?
It doesn't hurt to add class
attribute, so I can delete this part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's harmless.
Pinging @jquense – would be nice to get this merged :) Thanks! |
🎉 This PR is included in version 4.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fix #502