Skip to content
Permalink
Browse files

UI Tabs: fixed incomplete destroy method, fixes #3798

  • Loading branch information
Klaus Hartl
Klaus Hartl committed Jan 18, 2009
1 parent 6b887b5 commit 941f6feede6489024dc77a03065c59ac49231fa7
Showing with 29 additions and 3 deletions.
  1. +20 −2 tests/unit/tabs/tabs.js
  2. +9 −1 ui/ui.tabs.js
@@ -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();
@@ -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);
},

0 comments on commit 941f6fe

Please sign in to comment.
You can’t perform that action at this time.