diff --git a/src/collapse/collapse.js b/src/collapse/collapse.js index d0c0e236f..f898bb6e6 100644 --- a/src/collapse/collapse.js +++ b/src/collapse/collapse.js @@ -24,8 +24,9 @@ angular.module('mgcrea.ngStrap.collapse', []) // use string regex match boolean attr falsy values, leave truthy values be var falseValueRegExp = /^(false|0|)$/i; angular.forEach(['disallowToggle', 'startCollapsed', 'allowMultiple'], function(key) { - if(angular.isDefined($attrs[key]) && falseValueRegExp.test($attrs[key])) + if(angular.isDefined($attrs[key]) && falseValueRegExp.test($attrs[key])) { self.$options[key] = false; + } }); self.$toggles = []; @@ -210,7 +211,7 @@ angular.module('mgcrea.ngStrap.collapse', []) }); element.on('click', function() { - var index = attrs.bsCollapseToggle || bsCollapseCtrl.$toggles.indexOf(element); + var index = attrs.bsCollapseToggle && attrs.bsCollapseToggle !== 'bs-collapse-toggle' ? attrs.bsCollapseToggle : bsCollapseCtrl.$toggles.indexOf(element); bsCollapseCtrl.$setActive(index * 1); scope.$apply(); }); diff --git a/src/collapse/test/collapse.spec.js b/src/collapse/test/collapse.spec.js index 7ca9e641f..3474a8beb 100644 --- a/src/collapse/test/collapse.spec.js +++ b/src/collapse/test/collapse.spec.js @@ -28,6 +28,9 @@ describe('collapse', function () { 'default': { element: '
content-1
content-2
' }, + 'jade-attributes': { + element: '
content-1
content-2
' + }, 'template-ngRepeat': { scope: {panels: [ {title:'Collapsible Group Item #1', body: 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch.'}, @@ -108,6 +111,20 @@ describe('collapse', function () { }); + describe('with jade-like template', function () { + + it('should navigate between panels on click', function() { + var elm = compileDirective('jade-attributes'); + expect(sandboxEl.find('[bs-collapse-target]:eq(0)').hasClass('in')).toBeTruthy(); + sandboxEl.find('[bs-collapse-toggle]:eq(1)').triggerHandler('click'); + expect(sandboxEl.find('[bs-collapse-target]:eq(0)').hasClass('in')).toBeFalsy(); + expect(sandboxEl.find('[bs-collapse-target]:eq(1)').hasClass('in')).toBeTruthy(); + sandboxEl.find('[bs-collapse-toggle]:eq(1)').triggerHandler('click'); + expect(sandboxEl.find('[bs-collapse-target]:eq(1)').hasClass('in')).toBeFalsy(); + }); + + }); + describe('with ngRepeat template', function () { it('should navigate between panels on click', function() {