Skip to content
Permalink
Browse files

Tabs: Removed back-compat for load event. Fixes #8731 - Tabs: Remove …

…back-compat for load event.
  • Loading branch information...
scottgonzalez committed Oct 25, 2012
1 parent 828b3c4 commit 3d6c2a66d44a9283ad18e8c7c5ea701ddca82e59
Showing with 49 additions and 132 deletions.
  1. +0 −61 tests/unit/tabs/tabs_deprecated.js
  2. +47 −49 tests/unit/tabs/tabs_events.js
  3. +2 −10 tests/unit/tabs/tabs_methods.js
  4. +0 −12 ui/jquery.ui.tabs.js
@@ -66,67 +66,6 @@ test( "tabTemplate + panelTemplate", function() {
ok( element.find( "#new" ).hasClass( "customPanel" ), "panel custom class" );
});

module( "tabs (deprecated): events" );

asyncTest( "load", function() {
expect( 15 );

var tab, anchor, panelId, panel,
element = $( "#tabs2" );

// init
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 2 );
anchor = tab.find( ".ui-tabs-anchor" );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );

ok( !( "originalEvent" in event ), "originalEvent" );
strictEqual( ui.tab, anchor[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 1, 0, 0 );
tabsload1();
});
element.tabs({ active: 2 });

function tabsload1() {
// .option()
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 3 );
anchor = tab.find( ".ui-tabs-anchor" );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );

ok( !( "originalEvent" in event ), "originalEvent" );
strictEqual( ui.tab, anchor[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 0, 1, 0 );
tabsload2();
});
element.tabs( "option", "active", 3 );
}

function tabsload2() {
// click, change panel content
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 4 );
anchor = tab.find( ".ui-tabs-anchor" );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );

equal( event.originalEvent.type, "click", "originalEvent" );
strictEqual( ui.tab, anchor[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 0, 0, 1 );
start();
});
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 4 ).click();
}
});

module( "tabs (deprecated): methods" );

test( "add", function() {
@@ -253,16 +253,33 @@ test( "beforeLoad", function() {
equal( panel.html().toLowerCase(), "<p>testing</p>", "panel html after" );
});

if ( $.uiBackCompat === false ) {
asyncTest( "load", function() {
expect( 21 );
asyncTest( "load", function() {
expect( 21 );

var tab, panelId, panel,
element = $( "#tabs2" );
var tab, panelId, panel,
element = $( "#tabs2" );

// init
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 2 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );

ok( !( "originalEvent" in event ), "originalEvent" );
equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 1, 0, 0 );
tabsload1();
});
element.tabs({ active: 2 });

// init
function tabsload1() {
// .option()
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 2 );
tab = element.find( ".ui-tabs-nav li" ).eq( 3 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );

@@ -272,49 +289,30 @@ if ( $.uiBackCompat === false ) {
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 1, 0, 0 );
tabsload1();
state( element, 0, 0, 0, 1, 0 );
tabsload2();
});
element.tabs({ active: 2 });

function tabsload1() {
// .option()
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 3 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );

ok( !( "originalEvent" in event ), "originalEvent" );
equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 0, 1, 0 );
tabsload2();
});
element.tabs( "option", "active", 3 );
}
element.tabs( "option", "active", 3 );
}

function tabsload2() {
// click, change panel content
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 4 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );

equal( event.originalEvent.type, "click", "originalEvent" );
equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 0, 0, 1 );
start();
});
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 4 ).click();
}
});
}
function tabsload2() {
// click, change panel content
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 4 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );

equal( event.originalEvent.type, "click", "originalEvent" );
equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 0, 0, 1 );
start();
});
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 4 ).click();
}
});

}( jQuery ) );
@@ -198,11 +198,7 @@ asyncTest( "load", function() {

ok( !( "originalEvent" in event ), "originalEvent" );
equal( uiTab.length, 1, "tab length" );
if ( $.uiBackCompat === false ) {
strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
} else {
strictEqual( uiTab[ 0 ], tab.find( ".ui-tabs-anchor" )[ 0 ], "tab" );
}
strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
equal( uiPanel.length, 1, "panel length" );
strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
equal( uiPanel.find( "p" ).length, 1, "panel html" );
@@ -249,11 +245,7 @@ asyncTest( "load", function() {

ok( !( "originalEvent" in event ), "originalEvent" );
equal( uiTab.length, 1, "tab length" );
if ( $.uiBackCompat === false ) {
strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
} else {
strictEqual( uiTab[ 0 ], tab.find( ".ui-tabs-anchor" )[ 0 ], "tab" );
}
strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
equal( uiPanel.length, 1, "panel length" );
strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
state( element, 0, 0, 0, 1, 0 );
@@ -974,18 +974,6 @@ if ( $.uiBackCompat !== false ) {
.data( "ui-tabs-destroy", true );
}
});

// load event
$.widget( "ui.tabs", $.ui.tabs, {
_trigger: function( type, event, data ) {
var _data = $.extend( {}, data );
if ( type === "load" ) {
_data.panel = _data.panel[ 0 ];
_data.tab = _data.tab.find( ".ui-tabs-anchor" )[ 0 ];
}
return this._super( type, event, _data );
}
});
}

})( jQuery );

0 comments on commit 3d6c2a6

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