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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Accordion: don't toggle open class when is-open is undefined
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
inukshuk committed Sep 9, 2015
commit e84832001e17c21784e9e3808dbe52ff86cf1786
2 changes: 1 addition & 1 deletion src/accordion/accordion.js
Original file line number Diff line number Diff line change
@@ -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.

if (value) {
accordionCtrl.closeOthers(scope);
}