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

Commit 187f64c

Browse files
Foxandxsswesleycho
authored andcommitted
feat(tooltip): remove deprecated code
BREAKING CHANGE: Remove deprecated non-prefixed directives Close #4713
1 parent 80ede37 commit 187f64c

14 files changed

+24
-599
lines changed

src/popover/popover.js

+3-81
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
1010
replace: true,
1111
scope: { title: '@', contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
1212
originScope: '&' },
13-
templateUrl: 'template/popover/popover-template.html',
14-
link: function(scope, element) {
15-
element.addClass('popover');
16-
}
13+
templateUrl: 'template/popover/popover-template.html'
1714
};
1815
})
1916

@@ -27,10 +24,7 @@ angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
2724
return {
2825
replace: true,
2926
scope: { contentExp: '&', title: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
30-
templateUrl: 'template/popover/popover-html.html',
31-
link: function(scope, element) {
32-
element.addClass('popover');
33-
}
27+
templateUrl: 'template/popover/popover-html.html'
3428
};
3529
})
3630

@@ -44,82 +38,10 @@ angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
4438
return {
4539
replace: true,
4640
scope: { title: '@', content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
47-
templateUrl: 'template/popover/popover.html',
48-
link: function(scope, element) {
49-
element.addClass('popover');
50-
}
41+
templateUrl: 'template/popover/popover.html'
5142
};
5243
})
5344

5445
.directive('uibPopover', ['$uibTooltip', function($uibTooltip) {
5546
return $uibTooltip('uibPopover', 'popover', 'click');
5647
}]);
57-
58-
/* Deprecated popover below */
59-
60-
angular.module('ui.bootstrap.popover')
61-
62-
.value('$popoverSuppressWarning', false)
63-
64-
.directive('popoverTemplatePopup', ['$log', '$popoverSuppressWarning', function($log, $popoverSuppressWarning) {
65-
return {
66-
replace: true,
67-
scope: { title: '@', contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
68-
originScope: '&' },
69-
templateUrl: 'template/popover/popover-template.html',
70-
link: function(scope, element) {
71-
if (!$popoverSuppressWarning) {
72-
$log.warn('popover-template-popup is now deprecated. Use uib-popover-template-popup instead.');
73-
}
74-
75-
element.addClass('popover');
76-
}
77-
};
78-
}])
79-
80-
.directive('popoverTemplate', ['$tooltip', function($tooltip) {
81-
return $tooltip('popoverTemplate', 'popover', 'click', {
82-
useContentExp: true
83-
});
84-
}])
85-
86-
.directive('popoverHtmlPopup', ['$log', '$popoverSuppressWarning', function($log, $popoverSuppressWarning) {
87-
return {
88-
replace: true,
89-
scope: { contentExp: '&', title: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
90-
templateUrl: 'template/popover/popover-html.html',
91-
link: function(scope, element) {
92-
if (!$popoverSuppressWarning) {
93-
$log.warn('popover-html-popup is now deprecated. Use uib-popover-html-popup instead.');
94-
}
95-
96-
element.addClass('popover');
97-
}
98-
};
99-
}])
100-
101-
.directive('popoverHtml', ['$tooltip', function($tooltip) {
102-
return $tooltip('popoverHtml', 'popover', 'click', {
103-
useContentExp: true
104-
});
105-
}])
106-
107-
.directive('popoverPopup', ['$log', '$popoverSuppressWarning', function($log, $popoverSuppressWarning) {
108-
return {
109-
replace: true,
110-
scope: { title: '@', content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
111-
templateUrl: 'template/popover/popover.html',
112-
link: function(scope, element) {
113-
if (!$popoverSuppressWarning) {
114-
$log.warn('popover-popup is now deprecated. Use uib-popover-popup instead.');
115-
}
116-
117-
element.addClass('popover');
118-
}
119-
};
120-
}])
121-
122-
.directive('popover', ['$tooltip', function($tooltip) {
123-
124-
return $tooltip('popover', 'popover', 'click');
125-
}]);

src/popover/test/popover-html.spec.js

-61
Original file line numberDiff line numberDiff line change
@@ -187,64 +187,3 @@ describe('popover', function() {
187187
});
188188
});
189189
});
190-
191-
/* Deprecation tests below */
192-
193-
describe('popover deprecation', function() {
194-
beforeEach(module('ui.bootstrap.popover'));
195-
beforeEach(module('template/popover/popover-html.html'));
196-
197-
var elm, elmBody, elmScope, tooltipScope;
198-
199-
function trigger(element, evt) {
200-
evt = new Event(evt);
201-
202-
element[0].dispatchEvent(evt);
203-
element.scope().$$childTail.$digest();
204-
}
205-
206-
it('should suppress warning', function() {
207-
module(function($provide) {
208-
$provide.value('$popoverSuppressWarning', true);
209-
$provide.value('$tooltipSuppressWarning', true);
210-
});
211-
212-
inject(function($compile, $log, $rootScope, $sce) {
213-
spyOn($log, 'warn');
214-
215-
$rootScope.html = 'I say: <strong class="hello">Hello!</strong>';
216-
$rootScope.safeHtml = $sce.trustAsHtml($rootScope.html);
217-
elmBody = angular.element('<div><span popover-html="safeHtml">Selector Text</span></div>');
218-
$compile(elmBody)($rootScope);
219-
$rootScope.$digest();
220-
elm = elmBody.find('span');
221-
elmScope = elm.scope();
222-
tooltipScope = elmScope.$$childTail;
223-
224-
trigger(elm, 'mouseenter');
225-
tooltipScope.$digest();
226-
227-
expect($log.warn.calls.count()).toBe(0);
228-
});
229-
});
230-
231-
it('should give warning by default', inject(function($compile, $log, $rootScope, $sce) {
232-
spyOn($log, 'warn');
233-
234-
$rootScope.html = 'I say: <strong class="hello">Hello!</strong>';
235-
$rootScope.safeHtml = $sce.trustAsHtml($rootScope.html);
236-
elmBody = angular.element('<div><span popover-html="safeHtml">Selector Text</span></div>');
237-
$compile(elmBody)($rootScope);
238-
$rootScope.$digest();
239-
elm = elmBody.find('span');
240-
elmScope = elm.scope();
241-
tooltipScope = elmScope.$$childTail;
242-
243-
elm.trigger('click');
244-
tooltipScope.$digest();
245-
246-
expect($log.warn.calls.count()).toBe(2);
247-
expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
248-
expect($log.warn.calls.argsFor(1)).toEqual(['popover-html-popup is now deprecated. Use uib-popover-html-popup instead.']);
249-
}));
250-
});

src/popover/test/popover-template.spec.js

-53
Original file line numberDiff line numberDiff line change
@@ -125,56 +125,3 @@ describe('popover template', function() {
125125
});
126126
});
127127
});
128-
129-
/* Deprecation tests below */
130-
131-
describe('popover template deprecation', function() {
132-
beforeEach(module('ui.bootstrap.popover'));
133-
beforeEach(module('template/popover/popover.html'));
134-
beforeEach(module('template/popover/popover-template.html'));
135-
136-
var elm, elmBody, elmScope, tooltipScope;
137-
138-
it('should suppress warning', function() {
139-
module(function($provide) {
140-
$provide.value('$popoverSuppressWarning', true);
141-
$provide.value('$tooltipSuppressWarning', true);
142-
});
143-
144-
inject(function($compile, $log, $rootScope, $templateCache) {
145-
spyOn($log, 'warn');
146-
$templateCache.put('myUrl', [200, '<span>{{ myTemplateText }}</span>', {}]);
147-
$rootScope.templateUrl = 'myUrl';
148-
149-
elmBody = angular.element('<div><span popover-template="templateUrl">Selector Text</span></div>');
150-
$compile(elmBody)($rootScope);
151-
$rootScope.$digest();
152-
elm = elmBody.find('span');
153-
elmScope = elm.scope();
154-
tooltipScope = elmScope.$$childTail;
155-
156-
elm.trigger('click');
157-
tooltipScope.$digest();
158-
expect($log.warn.calls.count()).toBe(0);
159-
});
160-
});
161-
162-
it('should give warning by default', inject(function($compile, $log, $rootScope, $templateCache) {
163-
spyOn($log, 'warn');
164-
$templateCache.put('myUrl', [200, '<span>{{ myTemplateText }}</span>', {}]);
165-
$rootScope.templateUrl = 'myUrl';
166-
167-
elmBody = angular.element('<div><span popover-template="templateUrl">Selector Text</span></div>');
168-
$compile(elmBody)($rootScope);
169-
elm = elmBody.find('span');
170-
elmScope = elm.scope();
171-
tooltipScope = elmScope.$$childTail;
172-
173-
elm.trigger('click');
174-
tooltipScope.$digest();
175-
176-
expect($log.warn.calls.count()).toBe(2);
177-
expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
178-
expect($log.warn.calls.argsFor(1)).toEqual(['popover-template-popup is now deprecated. Use uib-popover-template-popup instead.']);
179-
}));
180-
});

src/popover/test/popover.spec.js

-50
Original file line numberDiff line numberDiff line change
@@ -174,53 +174,3 @@ describe('popover', function() {
174174
});
175175
});
176176
});
177-
178-
/* Deprecation tests below */
179-
180-
describe('popover deprecation', function() {
181-
beforeEach(module('ui.bootstrap.popover'));
182-
beforeEach(module('template/popover/popover.html'));
183-
184-
var elm, elmBody, elmScope, tooltipScope;
185-
186-
it('should suppress warning', function() {
187-
module(function($provide) {
188-
$provide.value('$popoverSuppressWarning', true);
189-
$provide.value('$tooltipSuppressWarning', true);
190-
});
191-
192-
inject(function($compile, $log, $rootScope) {
193-
spyOn($log, 'warn');
194-
195-
elmBody = angular.element('<div><span popover="popover text">Selector Text</span></div>');
196-
$compile(elmBody)($rootScope);
197-
$rootScope.$digest();
198-
elm = elmBody.find('span');
199-
elmScope = elm.scope();
200-
tooltipScope = elmScope.$$childTail;
201-
202-
elm.trigger('click');
203-
tooltipScope.$digest();
204-
205-
expect($log.warn.calls.count()).toBe(0);
206-
});
207-
});
208-
209-
it('should give warning by default', inject(function($compile, $log, $rootScope) {
210-
spyOn($log, 'warn');
211-
212-
elmBody = angular.element('<div><span popover="popover text">Selector Text</span></div>');
213-
$compile(elmBody)($rootScope);
214-
$rootScope.$digest();
215-
elm = elmBody.find('span');
216-
elmScope = elm.scope();
217-
tooltipScope = elmScope.$$childTail;
218-
219-
elm.trigger('click');
220-
tooltipScope.$digest();
221-
222-
expect($log.warn.calls.count()).toBe(2);
223-
expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
224-
expect($log.warn.calls.argsFor(1)).toEqual(['popover-popup is now deprecated. Use uib-popover-popup instead.']);
225-
}));
226-
});

src/tooltip/test/tooltip-template.spec.js

-62
Original file line numberDiff line numberDiff line change
@@ -82,65 +82,3 @@ describe('tooltip template', function() {
8282
expect(elmBody.children().length).toBe(1);
8383
}));
8484
});
85-
86-
/* Deprecation tests below */
87-
88-
describe('tooltip template deprecation', function() {
89-
beforeEach(module('ui.bootstrap.tooltip'));
90-
beforeEach(module('template/tooltip/tooltip-template-popup.html'));
91-
92-
var elm, elmBody, elmScope, tooltipScope;
93-
94-
function trigger(element, evt) {
95-
evt = new Event(evt);
96-
97-
element[0].dispatchEvent(evt);
98-
element.scope().$$childTail.$digest();
99-
}
100-
101-
it('should suppress warning', function() {
102-
module(function($provide) {
103-
$provide.value('$tooltipSuppressWarning', true);
104-
});
105-
106-
inject(function($compile, $log, $rootScope, $templateCache) {
107-
spyOn($log, 'warn');
108-
$templateCache.put('myUrl', [200, '<span>{{ myTemplateText }}</span>', {}]);
109-
$rootScope.templateUrl = 'myUrl';
110-
111-
elmBody = angular.element('<div><span tooltip-template="templateUrl">Selector Text</span></div>');
112-
$compile(elmBody)($rootScope);
113-
$rootScope.$digest();
114-
elm = elmBody.find('span');
115-
elmScope = elm.scope();
116-
tooltipScope = elmScope.$$childTail;
117-
118-
trigger(elm, 'mouseenter');
119-
120-
expect($log.warn.calls.count()).toBe(0);
121-
});
122-
});
123-
124-
it('should give warning by default', inject(function($compile, $log, $rootScope, $templateCache) {
125-
spyOn($log, 'warn');
126-
$templateCache.put('myUrl', [200, '<span>{{ myTemplateText }}</span>', {}]);
127-
$rootScope.templateUrl = 'myUrl';
128-
129-
var element = '<div><span tooltip-template="templateUrl">Selector Text</span></div>';
130-
element = $compile(element)($rootScope);
131-
$rootScope.$digest();
132-
133-
elmBody = angular.element('<div><span tooltip-template="templateUrl">Selector Text</span></div>');
134-
$compile(elmBody)($rootScope);
135-
$rootScope.$digest();
136-
elm = elmBody.find('span');
137-
elmScope = elm.scope();
138-
tooltipScope = elmScope.$$childTail;
139-
140-
trigger(elm, 'mouseenter');
141-
142-
expect($log.warn.calls.count()).toBe(2);
143-
expect($log.warn.calls.argsFor(0)).toEqual(['$tooltip is now deprecated. Use $uibTooltip instead.']);
144-
expect($log.warn.calls.argsFor(1)).toEqual(['tooltip-template-popup is now deprecated. Use uib-tooltip-template-popup instead.']);
145-
}));
146-
});

0 commit comments

Comments
 (0)