From fa5e448b17f8cf7f14260af130fbf8cda367c77a Mon Sep 17 00:00:00 2001 From: petarpetkovic Date: Tue, 29 May 2018 16:25:56 +0200 Subject: [PATCH] Update jquery.uls from upstream * Replace jQuery.proxy() with Function.prototype.bind() https://github.com/wikimedia/jquery.uls/commit/5dfca5fd8aa135a34aea85d7839b91ece499995c * Fix onInputChange being called twice https://github.com/wikimedia/jquery.uls/commit/44bd07f03801290973fc428dd53f00aa4cd75c7f Change-Id: I1de1c95d31cd8f5f8500d5f175cc54573cb0763f --- lib/jquery.uls/src/jquery.uls.core.js | 14 +++++++------- lib/jquery.uls/src/jquery.uls.languagefilter.js | 9 +++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/jquery.uls/src/jquery.uls.core.js b/lib/jquery.uls/src/jquery.uls.core.js index 28067bb7..893ae68f 100644 --- a/lib/jquery.uls/src/jquery.uls.core.js +++ b/lib/jquery.uls/src/jquery.uls.core.js @@ -220,7 +220,7 @@ columns: columnsOptions[ this.menuWidth ], quickList: languagesCount > 12 ? this.options.quickList : [], - clickhandler: $.proxy( this.select, this ), + clickhandler: this.select.bind( this ), showRegions: this.options.showRegions, languageDecorator: this.options.languageDecorator, noResultsTemplate: this.options.noResultsTemplate, @@ -233,10 +233,10 @@ languages: this.languages, ulsPurpose: this.options.ulsPurpose, searchAPI: this.options.searchAPI, - onSelect: $.proxy( this.select, this ) + onSelect: this.select.bind( this ) } ); - this.$languageFilter.on( 'noresults.uls', $.proxy( lcd.noResults, lcd ) ); + this.$languageFilter.on( 'noresults.uls', lcd.noResults.bind( lcd ) ); }, recreateLanguageFilter: function () { @@ -253,7 +253,7 @@ */ listen: function () { // Register all event listeners to the ULS here. - this.$element.on( 'click', $.proxy( this.click, this ) ); + this.$element.on( 'click', this.click.bind( this ) ); // Don't do anything if pressing on empty space in the ULS this.$menu.on( 'click', function ( e ) { @@ -261,13 +261,13 @@ } ); // Handle key press events on the menu - this.$menu.on( 'keydown', $.proxy( this.keypress, this ) ); + this.$menu.on( 'keydown', this.keypress.bind( this ) ); this.createLanguageFilter(); - this.$languageFilter.on( 'resultsfound.uls', $.proxy( this.success, this ) ); + this.$languageFilter.on( 'resultsfound.uls', this.success.bind( this ) ); - $( 'html' ).click( $.proxy( this.cancel, this ) ); + $( 'html' ).click( this.cancel.bind( this ) ); $( window ).resize( $.fn.uls.debounce( this.resize.bind( this ), 250 ) ); }, diff --git a/lib/jquery.uls/src/jquery.uls.languagefilter.js b/lib/jquery.uls/src/jquery.uls.languagefilter.js index 20346c73..4262efd7 100644 --- a/lib/jquery.uls/src/jquery.uls.languagefilter.js +++ b/lib/jquery.uls/src/jquery.uls.languagefilter.js @@ -58,14 +58,11 @@ }, listen: function () { - this.$element.on( 'keydown', $.proxy( this.keypress, this ) ); - this.$element.on( - 'change textInput input', - $.fn.uls.debounce( $.proxy( this.onInputChange, this ), 300 ) - ); + this.$element.on( 'keydown', this.keypress.bind( this ) ); + this.$element.on( 'input', $.fn.uls.debounce( this.onInputChange.bind( this ), 300 ) ); if ( this.$clear.length ) { - this.$clear.on( 'click', $.proxy( this.clear, this ) ); + this.$clear.on( 'click', this.clear.bind( this ) ); } this.toggleClear();