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

fix(accordion): re-expose AccordionController #4524

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
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.']);
}));
});