Gerrit Patch Uploader has uploaded a new change for review. https://gerrit.wikimedia.org/r/285580
Change subject: jquery.uls.core.js: Simplify by using Object.keys ...................................................................... jquery.uls.core.js: Simplify by using Object.keys Object.keys is guaranteed by es5-shim. Change-Id: I4bd070468526e26f069175334ef477fa8f9e9de7 --- M extension.json M lib/jquery.uls/src/jquery.uls.core.js 2 files changed, 3 insertions(+), 26 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector refs/changes/80/285580/1 diff --git a/extension.json b/extension.json index b953977..f483d76 100644 --- a/extension.json +++ b/extension.json @@ -315,6 +315,7 @@ "jquery.uls/css/jquery.uls.lcd.css" ], "dependencies": [ + "es5-shim", "jquery.i18n", "jquery.uls.data", "jquery.uls.grid" diff --git a/lib/jquery.uls/src/jquery.uls.core.js b/lib/jquery.uls/src/jquery.uls.core.js index f1d7354..bb510d6 100644 --- a/lib/jquery.uls/src/jquery.uls.core.js +++ b/lib/jquery.uls/src/jquery.uls.core.js @@ -52,30 +52,6 @@ /*jshint multistr:false */ /** - * Count the number of keys in an object. - * Works in a cross-browser way. - * @param {Object} The object. - */ - function objectLength ( obj ) { - var count, key; - - // Some old browsers don't support Object.keys - if ( Object.keys ) { - return Object.keys( obj ).length; - } - - count = 0; - - for ( key in obj ) { - if ( Object.prototype.hasOwnProperty.call( obj, key ) ) { - count++; - } - } - - return count; - } - - /** * ULS Public class definition */ ULS = function ( element, options ) { @@ -254,7 +230,7 @@ this.$menu.on( 'keydown', $.proxy( this.keypress, this ) ); } - languagesCount = objectLength( this.options.languages ); + languagesCount = Object.keys( this.options.languages ).length; lcd = this.$resultsView.lcd( { languages: this.languages, columns: columnsOptions[ this.getMenuWidth() ], @@ -382,7 +358,7 @@ return this.options.menuWidth; } - languagesCount = objectLength( this.options.languages ); + languagesCount = Object.keys( this.options.languages ).length; if ( languagesCount < 12 ) { return 'narrow'; -- To view, visit https://gerrit.wikimedia.org/r/285580 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4bd070468526e26f069175334ef477fa8f9e9de7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits