Skip to content

Commit b18c3a2

Browse files
committed
Merge pull request #1732 from tgirardi/destroy
Rename "remove" to "destroy" and create alias
2 parents 5e61cc9 + 9e60d0e commit b18c3a2

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

docs/methods.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ Methods are called on a datepicker by calling the ``datepicker`` function with a
88
$('.datepicker').datepicker('method', arg1, arg2);
99

1010

11-
remove
11+
destroy
1212
------
1313

1414
Arguments: None
1515

1616
Remove the datepicker. Removes attached events, internal attached objects, and added HTML elements.
1717

18+
*Alias: remove*
1819

1920
show
2021
----

js/bootstrap-datepicker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@
525525
return this;
526526
},
527527

528-
remove: function(){
528+
destroy: function(){
529529
this.hide();
530530
this._detachEvents();
531531
this._detachSecondaryEvents();
@@ -627,6 +627,7 @@
627627

628628
setDate: alias('setDates'),
629629
setUTCDate: alias('setUTCDates'),
630+
remove: alias('destroy'),
630631

631632
setValue: function(){
632633
var formatted = this.getFormattedDate();

tests/suites/component.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,27 @@ test('Selecting date resets viewDate and date', function(){
160160
equal(target.text(), '29'); // Should be Jan 29
161161
});
162162

163-
test('"remove" removes associated HTML', function(){
163+
test('"destroy" removes associated HTML', function(){
164164
var datepickerDivSelector = '.datepicker';
165165

166166
$('#datepicker').datepicker('show');
167167

168168
//there should be one datepicker initiated so that means one hidden .datepicker div
169169
equal($(datepickerDivSelector).length, 1);
170-
this.component.datepicker('remove');
170+
this.component.datepicker('destroy');
171171
equal($(datepickerDivSelector).length, 0);//hidden HTML should be gone
172172
});
173173

174+
test('"remove" is an alias for "destroy"', function(){
175+
var called, originalDestroy = this.dp.destroy;
176+
this.dp.destroy = function () {
177+
called = true;
178+
return originalDestroy.apply(this, arguments);
179+
};
180+
this.dp.remove();
181+
ok(called);
182+
});
183+
174184
test('Does not block events', function(){
175185
var clicks = 0;
176186
function handler(){

0 commit comments

Comments
 (0)