From: Scott González Date: Fri, 14 Dec 2012 16:13:46 +0000 (-0500) Subject: All: Use .addBack() instead of .andSelf(). X-Git-Tag: 1.10.0-rc.1~41 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8ec7a1b69ffd86edbef06e30ca4368600531e649;p=jquery-ui.git All: Use .addBack() instead of .andSelf(). --- diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js index 6d0bbbe88..dbc079818 100644 --- a/tests/unit/button/button_core.js +++ b/tests/unit/button/button_core.js @@ -138,7 +138,7 @@ test( "#7092 - button creation that requires a matching label does not find labe test( "#5946 - buttonset should ignore buttons that are not :visible", function() { expect( 2 ); - $( "#radio01" ).next().andSelf().hide(); + $( "#radio01" ).next().addBack().hide(); var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" }); ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) ); ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) ); diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js index a7e78ea69..c51d123c2 100644 --- a/tests/unit/menu/menu_methods.js +++ b/tests/unit/menu/menu_methods.js @@ -64,7 +64,7 @@ test( "refresh submenu", function() { expect( 2 ); var element = $( "#menu2" ).menu(); equal( element.find( "ul:first .ui-menu-item" ).length, 3 ); - element.find( "ul" ).andSelf().append( "
  • New Item
  • " ); + element.find( "ul" ).addBack().append( "
  • New Item
  • " ); element.menu("refresh"); equal( element.find( "ul:first .ui-menu-item" ).length, 4 ); }); diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 4ad4f8a09..694cb1bef 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -152,7 +152,7 @@ function focusable( element, isTabIndexNotNaN ) { function visible( element ) { return $.expr.filters.visible( element ) && - !$( element ).parents().andSelf().filter(function() { + !$( element ).parents().addBack().filter(function() { return $.css( this, "visibility" ) === "hidden"; }).length; } @@ -227,6 +227,15 @@ if ( !$( "" ).outerWidth( 1 ).jquery ) { }); } +// support: jQuery <1.8 +if ( !$.fn.addBack ) { + $.fn.addBack = function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter( selector ) + ); + }; +} + // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413) if ( $( "" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { $.fn.removeData = (function( removeData ) { diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index b982ac6be..63a9b9114 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -280,7 +280,7 @@ $.widget("ui.draggable", $.ui.mouse, { var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; $(this.options.handle, this.element) .find("*") - .andSelf() + .addBack() .each(function() { if(this === event.target) { handle = true; diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index e2da0b9f6..a6959fd0f 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -235,7 +235,7 @@ $.ui.ddmanager = { var i, j, m = $.ui.ddmanager.droppables[t.options.scope] || [], type = event ? event.type : null, // workaround for #2317 - list = (t.currentItem || t.element).find(":data(ui-droppable)").andSelf(); + list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack(); droppablesLoop: for (i = 0; i < m.length; i++) { diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index d8d32e932..83d78a9b4 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -761,7 +761,7 @@ $.effects.animateClass = function( value, duration, easing, callback ) { var animated = $( this ), baseClass = animated.attr( "class" ) || "", applyClassChange, - allAnimations = o.children ? animated.find( "*" ).andSelf() : animated; + allAnimations = o.children ? animated.find( "*" ).addBack() : animated; // map the animated objects to store the original styles. allAnimations = allAnimations.map(function() { diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 41a69c472..7f37b6b06 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -139,7 +139,7 @@ $.widget( "ui.menu", { // Destroy (sub)menus this.element .removeAttr( "aria-activedescendant" ) - .find( ".ui-menu" ).andSelf() + .find( ".ui-menu" ).addBack() .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" ) .removeAttr( "role" ) .removeAttr( "tabIndex" ) diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js index a9b15b20b..164862d14 100644 --- a/ui/jquery.ui.selectable.js +++ b/ui/jquery.ui.selectable.js @@ -113,7 +113,7 @@ $.widget("ui.selectable", $.ui.mouse, { } }); - $(event.target).parents().andSelf().each(function() { + $(event.target).parents().addBack().each(function() { var doSelect, selectee = $.data(this, "selectable-item"); if (selectee) { diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 02fee8364..4054f1848 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -256,7 +256,7 @@ $.widget( "ui.slider", $.ui.mouse, { .focus(); offset = closestHandle.offset(); - mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" ); + mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" ); this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { left: event.pageX - offset.left - ( closestHandle.width() / 2 ), top: event.pageY - offset.top - diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index e142a0ede..08de5b22a 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -126,7 +126,7 @@ $.widget("ui.sortable", $.ui.mouse, { return false; } if(this.options.handle && !overrideHandle) { - $(this.options.handle, currentItem).find("*").andSelf().each(function() { + $(this.options.handle, currentItem).find("*").addBack().each(function() { if(this === event.target) { validHandle = true; } diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index ab8d5173c..3984826ce 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -113,7 +113,7 @@ $.widget( "ui.tooltip", { }); // remove title attributes to prevent native tooltips - this.element.find( this.options.items ).andSelf().each(function() { + this.element.find( this.options.items ).addBack().each(function() { var element = $( this ); if ( element.is( "[title]" ) ) { element @@ -125,7 +125,7 @@ $.widget( "ui.tooltip", { _enable: function() { // restore title attributes - this.element.find( this.options.items ).andSelf().each(function() { + this.element.find( this.options.items ).addBack().each(function() { var element = $( this ); if ( element.data( "ui-tooltip-title" ) ) { element.attr( "title", element.data( "ui-tooltip-title" ) );