From 0cc705eafb48a8a5914763e96b8767bf38db19e3 Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Wed, 28 Sep 2016 16:31:36 +0300 Subject: [PATCH] Use String cast in pickup location comparison to avoid weak comparison. --- themes/bootstrap3/js/hold.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/bootstrap3/js/hold.js b/themes/bootstrap3/js/hold.js index 9015f999709..1359a489187 100644 --- a/themes/bootstrap3/js/hold.js +++ b/themes/bootstrap3/js/hold.js @@ -24,8 +24,8 @@ function setUpHoldRequestForm(recordId) { var defaultValue = $('#pickUpLocation').data('default'); $.each(response.data.locations, function holdPickupLocationEach() { var option = $('<option></option>').attr('value', this.locationID).text(this.locationDisplay); - // Weak comparison between locationID and defaultValue since locationID may be an integer - if (this.locationID === defaultValue || (defaultValue === '' && this.isDefault && $emptyOption.length === 0)) { + // Make sure to compare locationID and defaultValue as Strings since locationID may be an integer + if (String(this.locationID) === String(defaultValue) || (defaultValue === '' && this.isDefault && $emptyOption.length === 0)) { option.attr('selected', 'selected'); } $('#pickUpLocation').append(option); -- GitLab