From: Timo Tijhof Date: Fri, 17 Aug 2018 17:50:36 +0000 (+0100) Subject: jquery.suggestions: Remove dead code for returning options X-Git-Tag: 1.34.0-rc.0~4395^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=5415de59ae175f6e2282d8494350f0171d772703;p=lhc%2Fweb%2Fwiklou.git jquery.suggestions: Remove dead code for returning options 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 --- diff --git a/resources/src/jquery/jquery.suggestions.js b/resources/src/jquery/jquery.suggestions.js index 663950a604..35c6a5dfb7 100644 --- a/resources/src/jquery/jquery.suggestions.js +++ b/resources/src/jquery/jquery.suggestions.js @@ -6,10 +6,6 @@ * $( '#textbox' ).suggestions( { option1: value1, option2: value2 } ); * $( '#textbox' ).suggestions( option, value ); * - * Get option: - * - * value = $( '#textbox' ).suggestions( option ); - * * Initialize: * * $( '#textbox' ).suggestions(); @@ -578,10 +574,8 @@ // 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; @@ -624,9 +618,6 @@ 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 ] ] ); } } } @@ -776,7 +767,7 @@ // Store the context for next time $( this ).data( 'suggestions-context', context ); } ); - return returnValue !== undefined ? returnValue : $( this ); + return this; }; /**