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

Commit a15ff49

Browse files
committed
feat(accordion): remove deprecated code
BREAKING CHANGE: Remove deprecated non-prefixed directives
1 parent 0b04eef commit a15ff49

File tree

2 files changed

+0
-169
lines changed

2 files changed

+0
-169
lines changed

Diff for: src/accordion/accordion.js

-119
Original file line numberDiff line numberDiff line change
@@ -128,122 +128,3 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
128128
}
129129
};
130130
});
131-
132-
/* Deprecated accordion below */
133-
134-
angular.module('ui.bootstrap.accordion')
135-
136-
.value('$accordionSuppressWarning', false)
137-
138-
.controller('AccordionController', ['$scope', '$attrs', '$controller', '$log', '$accordionSuppressWarning', function($scope, $attrs, $controller, $log, $accordionSuppressWarning) {
139-
if (!$accordionSuppressWarning) {
140-
$log.warn('AccordionController is now deprecated. Use UibAccordionController instead.');
141-
}
142-
143-
angular.extend(this, $controller('UibAccordionController', {
144-
$scope: $scope,
145-
$attrs: $attrs
146-
}));
147-
}])
148-
149-
.directive('accordion', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
150-
return {
151-
restrict: 'EA',
152-
controller: 'AccordionController',
153-
controllerAs: 'accordion',
154-
transclude: true,
155-
replace: false,
156-
templateUrl: function(element, attrs) {
157-
return attrs.templateUrl || 'template/accordion/accordion.html';
158-
},
159-
link: function() {
160-
if (!$accordionSuppressWarning) {
161-
$log.warn('accordion is now deprecated. Use uib-accordion instead.');
162-
}
163-
}
164-
};
165-
}])
166-
167-
.directive('accordionGroup', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
168-
return {
169-
require: '^accordion', // We need this directive to be inside an accordion
170-
restrict: 'EA',
171-
transclude: true, // It transcludes the contents of the directive into the template
172-
replace: true, // The element containing the directive will be replaced with the template
173-
templateUrl: function(element, attrs) {
174-
return attrs.templateUrl || 'template/accordion/accordion-group.html';
175-
},
176-
scope: {
177-
heading: '@', // Interpolate the heading attribute onto this scope
178-
isOpen: '=?',
179-
isDisabled: '=?'
180-
},
181-
controller: function() {
182-
this.setHeading = function(element) {
183-
this.heading = element;
184-
};
185-
},
186-
link: function(scope, element, attrs, accordionCtrl) {
187-
if (!$accordionSuppressWarning) {
188-
$log.warn('accordion-group is now deprecated. Use uib-accordion-group instead.');
189-
}
190-
191-
accordionCtrl.addGroup(scope);
192-
193-
scope.openClass = attrs.openClass || 'panel-open';
194-
scope.panelClass = attrs.panelClass;
195-
scope.$watch('isOpen', function(value) {
196-
element.toggleClass(scope.openClass, !!value);
197-
if (value) {
198-
accordionCtrl.closeOthers(scope);
199-
}
200-
});
201-
202-
scope.toggleOpen = function($event) {
203-
if (!scope.isDisabled) {
204-
if (!$event || $event.which === 32) {
205-
scope.isOpen = !scope.isOpen;
206-
}
207-
}
208-
};
209-
}
210-
};
211-
}])
212-
213-
.directive('accordionHeading', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
214-
return {
215-
restrict: 'EA',
216-
transclude: true, // Grab the contents to be used as the heading
217-
template: '', // In effect remove this element!
218-
replace: true,
219-
require: '^accordionGroup',
220-
link: function(scope, element, attr, accordionGroupCtrl, transclude) {
221-
if (!$accordionSuppressWarning) {
222-
$log.warn('accordion-heading is now deprecated. Use uib-accordion-heading instead.');
223-
}
224-
// Pass the heading to the accordion-group controller
225-
// so that it can be transcluded into the right place in the template
226-
// [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat]
227-
accordionGroupCtrl.setHeading(transclude(scope, angular.noop));
228-
}
229-
};
230-
}])
231-
232-
.directive('accordionTransclude', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
233-
return {
234-
require: '^accordionGroup',
235-
link: function(scope, element, attr, controller) {
236-
if (!$accordionSuppressWarning) {
237-
$log.warn('accordion-transclude is now deprecated. Use uib-accordion-transclude instead.');
238-
}
239-
240-
scope.$watch(function() { return controller[attr.accordionTransclude]; }, function(heading) {
241-
if (heading) {
242-
element.find('span').html('');
243-
element.find('span').append(heading);
244-
}
245-
});
246-
}
247-
};
248-
}]);
249-

Diff for: src/accordion/test/accordion.spec.js

-50
Original file line numberDiff line numberDiff line change
@@ -583,53 +583,3 @@ describe('uib-accordion', function() {
583583
});
584584
});
585585
});
586-
587-
/* Deprecation tests below */
588-
589-
describe('accordion deprecation', function() {
590-
beforeEach(module('ui.bootstrap.accordion'));
591-
beforeEach(module('ngAnimateMock'));
592-
beforeEach(module('template/accordion/accordion.html'));
593-
beforeEach(module('template/accordion/accordion-group.html'));
594-
595-
it('should suppress warning', function() {
596-
module(function($provide) {
597-
$provide.value('$accordionSuppressWarning', true);
598-
});
599-
600-
inject(function($compile, $log, $rootScope) {
601-
spyOn($log, 'warn');
602-
603-
var element =
604-
'<accordion ng-init="a = [1,2,3]">' +
605-
'<accordion-group heading="I get overridden">' +
606-
'<div accordion-heading>Heading Element <span ng-repeat="x in a">{{x}}</span> </div>' +
607-
'Body' +
608-
'</accordion-group>' +
609-
'</accordion>';
610-
element = $compile(element)($rootScope);
611-
$rootScope.$digest();
612-
expect($log.warn.calls.count()).toBe(0);
613-
});
614-
});
615-
616-
it('should give warning by default', inject(function($compile, $log, $rootScope) {
617-
spyOn($log, 'warn');
618-
619-
var element =
620-
'<accordion ng-init="a = [1,2,3]">' +
621-
'<accordion-group heading="I get overridden">' +
622-
'<div accordion-heading>Heading Element <span ng-repeat="x in a">{{x}}</span> </div>' +
623-
'Body' +
624-
'</accordion-group>' +
625-
'</accordion>';
626-
element = $compile(element)($rootScope);
627-
$rootScope.$digest();
628-
629-
expect($log.warn.calls.count()).toBe(4);
630-
expect($log.warn.calls.argsFor(0)).toEqual(['AccordionController is now deprecated. Use UibAccordionController instead.']);
631-
expect($log.warn.calls.argsFor(1)).toEqual(['accordion-heading is now deprecated. Use uib-accordion-heading instead.']);
632-
expect($log.warn.calls.argsFor(2)).toEqual(['accordion-group is now deprecated. Use uib-accordion-group instead.']);
633-
expect($log.warn.calls.argsFor(3)).toEqual(['accordion is now deprecated. Use uib-accordion instead.']);
634-
}));
635-
});

0 commit comments

Comments
 (0)