Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Accordion: don't toggle open class when is-open is undefined #4385

Closed
wants to merge 1 commit into from

Conversation

inukshuk
Copy link
Contributor

@inukshuk inukshuk commented Sep 9, 2015

If is-open is not set the accordion group is closed, but the open class will be toggled, because jQuery expects a string or boolean (ignores undefined). See here: https://github.com/jquery/jquery/blob/c9cf250daafe806818da1dd207a88a8e94a4ad16/src/attributes/classes.js#L105

If `is-open` is not set the accordion group is closed, but the open class will be toggled, because jQuery expects a string or boolean (ignores undefined). See here: https://github.com/jquery/jquery/blob/c9cf250daafe806818da1dd207a88a8e94a4ad16/src/attributes/classes.js#L105
@@ -82,7 +82,7 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
scope.openClass = attrs.openClass || 'panel-open';
scope.panelClass = attrs.panelClass;
scope.$watch('isOpen', function(value) {
element.toggleClass(scope.openClass, value);
element.toggleClass(scope.openClass, Boolean(value));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change this to !!value - the reason is because the Boolean constructor can be overridden by the user, whereas using !! to force to a Boolean cannot be overridden.

@wesleycho
Copy link
Contributor

Scratch that, made the change - c064748 . Thanks for the find!

@inukshuk
Copy link
Contributor Author

inukshuk commented Sep 9, 2015

Thanks!

jasonaden pushed a commit to deskfed/bootstrap that referenced this pull request Jan 8, 2016
- Coerce `toggleClass` argument to boolean due to jQuery ignoring
  `undefined`

Closes angular-ui#4385
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants