jquery.suggestions: Remove dead code for returning options
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 17 Aug 2018 17:50:36 +0000 (18:50 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 17 Aug 2018 17:50:36 +0000 (18:50 +0100)
    returnValue = (key in obj) ? undefined : obj[key];

By standard, this cannot return anything other undefined.
This code has been broken since the introduction of the module
in 2012 (32377424b, r72349).

The functionality also didn't have test (naturally), and isn't
used anywhere in Wikimedia Git. Simply remove it.

Also remove the confusing $() wrapping of the non-getter return
value that provides chainability.

The 'this' inside a jQuery method is already an instance of jQuery,
pulling it through $() again achieves very little.

Change-Id: Id13861d42b65a759d74670d8c5850aecee4daf7d

resources/src/jquery/jquery.suggestions.js

index 663950a..35c6a5d 100644 (file)
@@ -6,10 +6,6 @@
  *             $( '#textbox' ).suggestions( { option1: value1, option2: value2 } );
  *             $( '#textbox' ).suggestions( option, value );
  *
- * Get option:
- *
- *             value = $( '#textbox' ).suggestions( option );
- *
  * Initialize:
  *
  *             $( '#textbox' ).suggestions();
 
        // See file header for method documentation
        $.fn.suggestions = function () {
-
                // Multi-context fields
-               var returnValue,
-                       args = arguments;
+               var args = arguments;
 
                $( this ).each( function () {
                        var context, key;
                                        if ( args.length > 1 ) {
                                                // Set property values
                                                $.suggestions.configure( context, args[ 0 ], args[ 1 ] );
-                                       } else if ( returnValue === null || returnValue === undefined ) {
-                                               // Get property values, but don't give access to internal data - returns only the first
-                                               returnValue = ( args[ 0 ] in context.config ? undefined : context.config[ args[ 0 ] ] );
                                        }
                                }
                        }
                        // Store the context for next time
                        $( this ).data( 'suggestions-context', context );
                } );
-               return returnValue !== undefined ? returnValue : $( this );
+               return this;
        };
 
        /**