]> source.dussan.org Git - jquery-ui.git/commitdiff
All: Use .addBack() instead of .andSelf().
authorScott González <scott.gonzalez@gmail.com>
Fri, 14 Dec 2012 16:13:46 +0000 (11:13 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 14 Dec 2012 16:13:50 +0000 (11:13 -0500)
tests/unit/button/button_core.js
tests/unit/menu/menu_methods.js
ui/jquery.ui.core.js
ui/jquery.ui.draggable.js
ui/jquery.ui.droppable.js
ui/jquery.ui.effect.js
ui/jquery.ui.menu.js
ui/jquery.ui.selectable.js
ui/jquery.ui.slider.js
ui/jquery.ui.sortable.js
ui/jquery.ui.tooltip.js

index 6d0bbbe88788ba2e1b9298f5bf76729a6e507a85..dbc079818393c3935de1d7c00b84757e6f6bdcb4 100644 (file)
@@ -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" ) );
index a7e78ea699453249177d069ec0109cd4378b2ee4..c51d123c2d74f723f6ae29f6fa1e8990e7af4077 100644 (file)
@@ -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( "<li><a href=\"#\">New Item</a></li>" );
+       element.find( "ul" ).addBack().append( "<li><a href=\"#\">New Item</a></li>" );
        element.menu("refresh");
        equal( element.find( "ul:first .ui-menu-item" ).length, 4 );
 });
index 4ad4f8a0903d11a6243c0a6eaea1b676a814bfc6..694cb1bef6f2156b9ad2cc948ea5ce4b78716284 100644 (file)
@@ -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 ( !$( "<a>" ).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 ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
        $.fn.removeData = (function( removeData ) {
index b982ac6be3242cfb6f4911c645b0a750c2d826bd..63a9b9114e16fca2fc7ab6fbc4ad875081523290 100644 (file)
@@ -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;
index e2da0b9f6b799f2b991ade0664e6c47de080b04d..a6959fd0f2b87031faa62642a7425f45677ad663 100644 (file)
@@ -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++) {
 
index d8d32e932ded0a172e29008d36c1f35585214036..83d78a9b4e45bae097296402b37698c429440bc4 100644 (file)
@@ -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() {
index 41a69c4723a81b4926d40223dcc2aae0f23dc724..7f37b6b06dcd45c1673f11601f3c435ee5626a29 100644 (file)
@@ -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" )
index a9b15b20b7f67fe43a8389e8beba315a3ebcc033..164862d14354de8f7cab84d410834552c2c898bb 100644 (file)
@@ -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) {
index 02fee8364fbae0fb8283213e60eeb1bf56702be4..4054f1848c338ea615ee4b04f98a1b4af2512176 100644 (file)
@@ -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 -
index e142a0edeb874e244c3baf6841682e11fa125b92..08de5b22a36e99b52a5f13682aebcea5e1ea6e17 100644 (file)
@@ -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;
                                }
index ab8d5173c0f58869694fc65cde37d02f05cef879..3984826ce1b39b482b418551f0857b9d4157c6fc 100644 (file)
@@ -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" ) );