Skip to content

Commit 8ec7a1b

Browse files
committed
All: Use .addBack() instead of .andSelf().
1 parent 80e46c9 commit 8ec7a1b

11 files changed

+21
-12
lines changed

tests/unit/button/button_core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ test( "#7092 - button creation that requires a matching label does not find labe
138138

139139
test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
140140
expect( 2 );
141-
$( "#radio01" ).next().andSelf().hide();
141+
$( "#radio01" ).next().addBack().hide();
142142
var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
143143
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
144144
ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) );

tests/unit/menu/menu_methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test( "refresh submenu", function() {
6464
expect( 2 );
6565
var element = $( "#menu2" ).menu();
6666
equal( element.find( "ul:first .ui-menu-item" ).length, 3 );
67-
element.find( "ul" ).andSelf().append( "<li><a href=\"#\">New Item</a></li>" );
67+
element.find( "ul" ).addBack().append( "<li><a href=\"#\">New Item</a></li>" );
6868
element.menu("refresh");
6969
equal( element.find( "ul:first .ui-menu-item" ).length, 4 );
7070
});

ui/jquery.ui.core.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function focusable( element, isTabIndexNotNaN ) {
152152

153153
function visible( element ) {
154154
return $.expr.filters.visible( element ) &&
155-
!$( element ).parents().andSelf().filter(function() {
155+
!$( element ).parents().addBack().filter(function() {
156156
return $.css( this, "visibility" ) === "hidden";
157157
}).length;
158158
}
@@ -227,6 +227,15 @@ if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
227227
});
228228
}
229229

230+
// support: jQuery <1.8
231+
if ( !$.fn.addBack ) {
232+
$.fn.addBack = function( selector ) {
233+
return this.add( selector == null ?
234+
this.prevObject : this.prevObject.filter( selector )
235+
);
236+
};
237+
}
238+
230239
// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
231240
if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
232241
$.fn.removeData = (function( removeData ) {

ui/jquery.ui.draggable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ $.widget("ui.draggable", $.ui.mouse, {
280280
var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
281281
$(this.options.handle, this.element)
282282
.find("*")
283-
.andSelf()
283+
.addBack()
284284
.each(function() {
285285
if(this === event.target) {
286286
handle = true;

ui/jquery.ui.droppable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ $.ui.ddmanager = {
235235
var i, j,
236236
m = $.ui.ddmanager.droppables[t.options.scope] || [],
237237
type = event ? event.type : null, // workaround for #2317
238-
list = (t.currentItem || t.element).find(":data(ui-droppable)").andSelf();
238+
list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
239239

240240
droppablesLoop: for (i = 0; i < m.length; i++) {
241241

ui/jquery.ui.effect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
761761
var animated = $( this ),
762762
baseClass = animated.attr( "class" ) || "",
763763
applyClassChange,
764-
allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
764+
allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
765765

766766
// map the animated objects to store the original styles.
767767
allAnimations = allAnimations.map(function() {

ui/jquery.ui.menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ $.widget( "ui.menu", {
139139
// Destroy (sub)menus
140140
this.element
141141
.removeAttr( "aria-activedescendant" )
142-
.find( ".ui-menu" ).andSelf()
142+
.find( ".ui-menu" ).addBack()
143143
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
144144
.removeAttr( "role" )
145145
.removeAttr( "tabIndex" )

ui/jquery.ui.selectable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ $.widget("ui.selectable", $.ui.mouse, {
113113
}
114114
});
115115

116-
$(event.target).parents().andSelf().each(function() {
116+
$(event.target).parents().addBack().each(function() {
117117
var doSelect,
118118
selectee = $.data(this, "selectable-item");
119119
if (selectee) {

ui/jquery.ui.slider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ $.widget( "ui.slider", $.ui.mouse, {
256256
.focus();
257257

258258
offset = closestHandle.offset();
259-
mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
259+
mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
260260
this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
261261
left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
262262
top: event.pageY - offset.top -

ui/jquery.ui.sortable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ $.widget("ui.sortable", $.ui.mouse, {
126126
return false;
127127
}
128128
if(this.options.handle && !overrideHandle) {
129-
$(this.options.handle, currentItem).find("*").andSelf().each(function() {
129+
$(this.options.handle, currentItem).find("*").addBack().each(function() {
130130
if(this === event.target) {
131131
validHandle = true;
132132
}

ui/jquery.ui.tooltip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ $.widget( "ui.tooltip", {
113113
});
114114

115115
// remove title attributes to prevent native tooltips
116-
this.element.find( this.options.items ).andSelf().each(function() {
116+
this.element.find( this.options.items ).addBack().each(function() {
117117
var element = $( this );
118118
if ( element.is( "[title]" ) ) {
119119
element
@@ -125,7 +125,7 @@ $.widget( "ui.tooltip", {
125125

126126
_enable: function() {
127127
// restore title attributes
128-
this.element.find( this.options.items ).andSelf().each(function() {
128+
this.element.find( this.options.items ).addBack().each(function() {
129129
var element = $( this );
130130
if ( element.data( "ui-tooltip-title" ) ) {
131131
element.attr( "title", element.data( "ui-tooltip-title" ) );

0 commit comments

Comments
 (0)