-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Adds the class directive #1685
Adds the class directive #1685
Conversation
Allows `<div class:active="user.active">` to simplify templates littered with ternary statements. Addresses #890
src/shared/dom.js
Outdated
|
||
export function toggleClass(element, name, toggle) { | ||
element.classList.toggle(name, Boolean(toggle)); |
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 the Boolean
here? In Chrome at least it coerce the value for us
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.
Update: tested in Chrome, Firefox and Safari. I reckon we can do without — I'll delete it
Thank you! |
@Rich-Harris the
The |
^ Yup! It bugs me that We can do |
Oh yeah, of course. |
Disagree on Since it's generated code it probably isn't very important but I'll always advocate for code clarity over tricks, even well-known ones. |
Whoops. Good catch. Fixed in 2.13.1 — I went with |
Allows
<div class:active="user.active">
to simplify templates littered with ternary statements.Addresses #890