From b6a30c3d44b840bc3136c9b6c0b2c365d9bee146 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Tue, 27 Jan 2015 10:16:13 -0800 Subject: [PATCH] Restore support for IE8 IE8 does not support Object.keys. https://phabricator.wikimedia.org/T86516 Copying the patch from Gerrit: https://gerrit.wikimedia.org/r/#/c/184316/ --- src/jquery.uls.core.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/jquery.uls.core.js b/src/jquery.uls.core.js index 40819d4..fba4859 100644 --- a/src/jquery.uls.core.js +++ b/src/jquery.uls.core.js @@ -354,13 +354,26 @@ * @return string */ getMenuWidth: function () { - var languagesCount; + var language, + languagesCount = 0; if ( this.options.menuWidth ) { return this.options.menuWidth; } - languagesCount = Object.keys( this.options.languages ).length; + // IE8 does not support Object.keys + if ( Object.keys ) { + languagesCount = Object.keys( this.options.languages ).length; + } else { + for ( language in this.options.languages ) { + if ( Object.prototype.hasOwnProperty.call( + this.options.languages, + language + ) ) { + languagesCount++; + } + } + } if ( languagesCount < 12 ) { return 'narrow';