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

Commit

Permalink
fix(accordion): re-expose AccordionController
Browse files Browse the repository at this point in the history
- Expose `AccordionController` with deprecation message

Closes #4524
  • Loading branch information
wesleycho committed Oct 3, 2015
1 parent db36c62 commit 5382226
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 12 additions & 1 deletion src/accordion/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,21 @@ angular.module('ui.bootstrap.accordion')

.value('$accordionSuppressWarning', false)

.controller('AccordionController', ['$scope', '$attrs', '$controller', '$log', '$accordionSuppressWarning', function($scope, $attrs, $controller, $log, $accordionSuppressWarning) {
if (!$accordionSuppressWarning) {
$log.warn('AccordionController is now deprecated. Use UibAccordionController instead.');
}

angular.extend(this, $controller('UibAccordionController', {
$scope: $scope,
$attrs: $attrs
}));
}])

.directive('accordion', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
return {
restrict: 'EA',
controller: 'UibAccordionController',
controller: 'AccordionController',
controllerAs: 'accordion',
transclude: true,
replace: false,
Expand Down
10 changes: 5 additions & 5 deletions src/accordion/test/accordion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('uib-accordion', function() {
}));

describe('controller', function () {

var ctrl, $element, $attrs;
beforeEach(inject(function($controller) {
$attrs = {};
Expand Down Expand Up @@ -627,9 +626,10 @@ describe('accordion deprecation', function() {
element = $compile(element)($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(3);
expect($log.warn.calls.argsFor(0)).toEqual(['accordion-heading is now deprecated. Use uib-accordion-heading instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['accordion-group is now deprecated. Use uib-accordion-group instead.']);
expect($log.warn.calls.argsFor(2)).toEqual(['accordion is now deprecated. Use uib-accordion instead.']);
expect($log.warn.calls.count()).toBe(4);
expect($log.warn.calls.argsFor(0)).toEqual(['AccordionController is now deprecated. Use UibAccordionController instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['accordion-heading is now deprecated. Use uib-accordion-heading instead.']);
expect($log.warn.calls.argsFor(2)).toEqual(['accordion-group is now deprecated. Use uib-accordion-group instead.']);
expect($log.warn.calls.argsFor(3)).toEqual(['accordion is now deprecated. Use uib-accordion instead.']);
}));
});

0 comments on commit 5382226

Please sign in to comment.