Skip to content
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

Support falsy values in classes binding #292

Closed
bmuenzenmeyer opened this issue Jul 10, 2015 · 3 comments
Closed

Support falsy values in classes binding #292

bmuenzenmeyer opened this issue Jul 10, 2015 · 3 comments

Comments

@bmuenzenmeyer
Copy link

I love the new classes hash but find myself at a loss with how to evaluate a falsy value quickly.

Previous to 0.9.* I had this binding like this:

'.disableIcon': {
    attributes: [
        {
            name: 'class',
            observe: 'isDisabled',
            onGet: function(value, options) {
                return value ? 'icon-unlock' : 'icon-lock';
            }
        }
    ]
},

As far as I understand, I can only replace one side of this situation, like so:

'.disableIcon': {
    classes: {
        'icon-unlock': 'isDisabled'
    }
},

requiring me to still still evaluate the falsy path using the old attribute syntax.
Would there be some way to accomplish the following?

'.disableIcon': {
    classes: {
        'icon-unlock': 'isDisabled',
        'icon-lock': !'isDisabled'
    }
},

Not a show stopper, and again, I might be going about it the wrong way. Either way, thanks for the great library!

@akre54
Copy link
Contributor

akre54 commented Jul 10, 2015

Yeah unfortunately with the simple key -> val syntax it doesn't leave any room for extra options. One idea is we could support {'icon-unlock': '!isDisabled'}, and run a regex against the first !, but in a perfect world I'd rather we keep away from string programming if we can, as it tends to open a whole slew of new problems. Open to other suggestions if you have any, but I'd say stick with the function for now.

@akre54 akre54 closed this as completed Jul 10, 2015
@bmuenzenmeyer
Copy link
Author

Okay by me - the issue was more a question to make sure I didn't miss something obvious.

Thanks for the quick response!

@victorwpbastos
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants