UI Tabs: fixed incomplete destroy method, fixes #3798

This commit is contained in:
Klaus Hartl 2009-01-18 21:09:31 +00:00
parent 6b887b5efd
commit 941f6feede
2 changed files with 29 additions and 3 deletions

View File

@ -55,7 +55,25 @@ module('tabs');
});
test('destroy', function() {
expect(0);
expect(14);
var el = $('#tabs1').tabs(); // new markup requires to tabify wrapper again...
el.tabs('destroy');
ok( el.is(':not(.ui-tabs)'), 'remove classes from container');
ok( el.is(':not(.ui-widget)'), 'remove classes from container');
ok( el.is(':not(.ui-widget-content)'), 'remove classes from container');
ok( el.is(':not(.ui-corner-all)'), 'remove classes from container');
ok( $('ul', el).is(':not(.ui-tabs-nav)'), 'remove classes from list' );
ok( $('ul', el).is(':not(.ui-helper-reset)'), 'remove classes from list' );
ok( $('ul', el).is(':not(.ui-helper-clearfix)'), 'remove classes from list' );
ok( $('ul', el).is(':not(.ui-widget-header)'), 'remove classes from list' );
ok( $('ul', el).is(':not(.ui-corner-all)'), 'remove classes from list' );
ok( $('li:eq(0)', el).is(':not(.ui-tabs-selected)'), 'remove classes from active li');
ok( $('li:eq(0)', el).is(':not(.ui-state-active)'), 'remove classes from active li');
ok( $('li:eq(0)', el).is(':not(.ui-corner-top)'), 'remove classes from active li');
ok( $('li:eq(1)', el).is(':not(.ui-state-default)'), 'remove classes from inactive li');
ok( $('li:eq(1)', el).is(':not(.ui-corner-top)'), 'remove classes from inactive li');
});
@ -189,7 +207,7 @@ module('tabs: Options');
module('tabs: Tickets');
test('id containing colon, #????', function() {
test('id containing colon, #2715', function() { // http://ui.jquery.com/bugs/ticket/2715
expect(4);
var el = $('#tabs2 > ul').tabs();

View File

@ -21,8 +21,14 @@ $.widget("ui.tabs", {
destroy: function() {
var o = this.options;
this.element
.removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all');
this.list.unbind('.tabs')
.removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all').removeData('tabs');
.removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all')
.removeData('tabs');
this.$tabs.each(function() {
var href = $.data(this, 'href.tabs');
if (href)
@ -32,6 +38,7 @@ $.widget("ui.tabs", {
$this.removeData(prefix + '.tabs');
});
});
this.$lis.unbind('.tabs').add(this.$panels).each(function() {
if ($.data(this, 'destroy.tabs'))
$(this).remove();
@ -48,6 +55,7 @@ $.widget("ui.tabs", {
'ui-corner-bottom ' +
'ui-tabs-hide');
});
if (o.cookie)
this._cookie(null, o.cookie);
},