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

Commit bc004df

Browse files
Foxandxsswesleycho
authored andcommitted
feat(collapse): remove deprecated code
BREAKING CHANGE: Remove deprecated non-prefixed directives Closes #4715
1 parent 21e852b commit bc004df

File tree

2 files changed

+0
-116
lines changed

2 files changed

+0
-116
lines changed

src/collapse/collapse.js

-83
Original file line numberDiff line numberDiff line change
@@ -74,86 +74,3 @@ angular.module('ui.bootstrap.collapse', [])
7474
}
7575
};
7676
}]);
77-
78-
/* Deprecated collapse below */
79-
80-
angular.module('ui.bootstrap.collapse')
81-
82-
.value('$collapseSuppressWarning', false)
83-
84-
.directive('collapse', ['$animate', '$injector', '$log', '$collapseSuppressWarning', function($animate, $injector, $log, $collapseSuppressWarning) {
85-
var $animateCss = $injector.has('$animateCss') ? $injector.get('$animateCss') : null;
86-
return {
87-
link: function(scope, element, attrs) {
88-
if (!$collapseSuppressWarning) {
89-
$log.warn('collapse is now deprecated. Use uib-collapse instead.');
90-
}
91-
92-
function expand() {
93-
element.removeClass('collapse')
94-
.addClass('collapsing')
95-
.attr('aria-expanded', true)
96-
.attr('aria-hidden', false);
97-
98-
if ($animateCss) {
99-
$animateCss(element, {
100-
easing: 'ease',
101-
to: { height: element[0].scrollHeight + 'px' }
102-
}).start().done(expandDone);
103-
} else {
104-
$animate.animate(element, {}, {
105-
height: element[0].scrollHeight + 'px'
106-
}).then(expandDone);
107-
}
108-
}
109-
110-
function expandDone() {
111-
element.removeClass('collapsing')
112-
.addClass('collapse in')
113-
.css({height: 'auto'});
114-
}
115-
116-
function collapse() {
117-
if (!element.hasClass('collapse') && !element.hasClass('in')) {
118-
return collapseDone();
119-
}
120-
121-
element
122-
// IMPORTANT: The height must be set before adding "collapsing" class.
123-
// Otherwise, the browser attempts to animate from height 0 (in
124-
// collapsing class) to the given height here.
125-
.css({height: element[0].scrollHeight + 'px'})
126-
// initially all panel collapse have the collapse class, this removal
127-
// prevents the animation from jumping to collapsed state
128-
.removeClass('collapse in')
129-
.addClass('collapsing')
130-
.attr('aria-expanded', false)
131-
.attr('aria-hidden', true);
132-
133-
if ($animateCss) {
134-
$animateCss(element, {
135-
to: {height: '0'}
136-
}).start().done(collapseDone);
137-
} else {
138-
$animate.animate(element, {}, {
139-
height: '0'
140-
}).then(collapseDone);
141-
}
142-
}
143-
144-
function collapseDone() {
145-
element.css({height: '0'}); // Required so that collapse works when animation is disabled
146-
element.removeClass('collapsing')
147-
.addClass('collapse');
148-
}
149-
150-
scope.$watch(attrs.collapse, function(shouldCollapse) {
151-
if (shouldCollapse) {
152-
collapse();
153-
} else {
154-
expand();
155-
}
156-
});
157-
}
158-
};
159-
}]);

src/collapse/test/collapse.spec.js

-33
Original file line numberDiff line numberDiff line change
@@ -130,36 +130,3 @@ describe('collapse directive', function() {
130130
});
131131
});
132132
});
133-
134-
/* Deprecation tests below */
135-
136-
describe('collapse deprecation', function() {
137-
beforeEach(module('ui.bootstrap.collapse'));
138-
beforeEach(module('ngAnimateMock'));
139-
140-
it('should suppress warning', function() {
141-
module(function($provide) {
142-
$provide.value('$collapseSuppressWarning', true);
143-
});
144-
145-
inject(function($compile, $log, $rootScope) {
146-
spyOn($log, 'warn');
147-
148-
var element = $compile('<div collapse="isCollapsed">Some Content</div>')($rootScope);
149-
$rootScope.$digest();
150-
151-
expect($log.warn.calls.count()).toBe(0);
152-
});
153-
});
154-
155-
it('should give warning by default', inject(function($compile, $log, $rootScope) {
156-
spyOn($log, 'warn');
157-
158-
var element = $compile('<div collapse="isCollapsed">Some Content</div>')($rootScope);
159-
$rootScope.$digest();
160-
161-
expect($log.warn.calls.count()).toBe(1);
162-
expect($log.warn.calls.argsFor(0)).toEqual(['collapse is now deprecated. Use uib-collapse instead.']);
163-
164-
}));
165-
});

0 commit comments

Comments
 (0)