From a4f61a832e7ac3b94f8e3446b727ecdd46710743 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 1 Jul 2019 16:02:07 +0100 Subject: [PATCH] CollapsibleTabs: Avoid Sizzle selectors Change-Id: I199a11602df50f2120dce6f861bb4b6260ab9380 --- collapsibleTabs.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/collapsibleTabs.js b/collapsibleTabs.js index a23520a..79036ef 100644 --- a/collapsibleTabs.js +++ b/collapsibleTabs.js @@ -96,7 +96,9 @@ }, handleResize: function () { $.collapsibleTabs.instances.forEach( function ( $el ) { - var data = $.collapsibleTabs.getSettings( $el ); + var $tab, + data = $.collapsibleTabs.getSettings( $el ); + if ( data.shifting ) { return; } @@ -105,24 +107,21 @@ if ( $el.children( data.collapsible ).length && data.collapseCondition() ) { $el.trigger( 'beforeTabCollapse' ); // move the element to the dropdown menu - $.collapsibleTabs.moveToCollapsed( $el.children( data.collapsible + ':last' ) ); + $.collapsibleTabs.moveToCollapsed( $el.children( data.collapsible ).last() ); } + $tab = $( data.collapsedContainer ).children( data.collapsible ).first(); // if there are still moveable items in the dropdown menu, // and there is sufficient space to place them in the tab container if ( $( data.collapsedContainer + ' ' + data.collapsible ).length && data.expandCondition( - $.collapsibleTabs.getSettings( - $( data.collapsedContainer ).children( - data.collapsible + ':first' ) - ).expandedWidth + $.collapsibleTabs.getSettings( $tab ).expandedWidth ) ) { // move the element from the dropdown to the tab $el.trigger( 'beforeTabExpand' ); - $.collapsibleTabs - .moveToExpanded( data.collapsedContainer + ' ' + data.collapsible + ':first' ); + $.collapsibleTabs.moveToExpanded( $tab ); } } ); }, @@ -156,9 +155,8 @@ rAF( $.collapsibleTabs.handleResize ); } ); }, - moveToExpanded: function ( ele ) { - var data, expContainerSettings, $target, expandedWidth, - $moving = $( ele ); + moveToExpanded: function ( $moving ) { + var data, expContainerSettings, $target, expandedWidth; data = $.collapsibleTabs.getSettings( $moving ); if ( !data ) { @@ -171,7 +169,7 @@ expContainerSettings.shifting = true; // grab the next appearing placeholder so we can use it for replacing - $target = $( data.expandedContainer ).find( 'span.placeholder:first' ); + $target = $( data.expandedContainer ).find( 'span.placeholder' ).first(); expandedWidth = data.expandedWidth; $moving.css( 'position', 'relative' ).css( ( isRTL ? 'right' : 'left' ), 0 ).css( 'width', '1px' ); $target.replaceWith(