Skip to content
Snippets Groups Projects
Commit 0cc705ea authored by Ere Maijala's avatar Ere Maijala Committed by Demian Katz
Browse files

Use String cast in pickup location comparison to avoid weak comparison.

parent d4388e57
No related merge requests found
...@@ -24,8 +24,8 @@ function setUpHoldRequestForm(recordId) { ...@@ -24,8 +24,8 @@ function setUpHoldRequestForm(recordId) {
var defaultValue = $('#pickUpLocation').data('default'); var defaultValue = $('#pickUpLocation').data('default');
$.each(response.data.locations, function holdPickupLocationEach() { $.each(response.data.locations, function holdPickupLocationEach() {
var option = $('<option></option>').attr('value', this.locationID).text(this.locationDisplay); var option = $('<option></option>').attr('value', this.locationID).text(this.locationDisplay);
// Weak comparison between locationID and defaultValue since locationID may be an integer // Make sure to compare locationID and defaultValue as Strings since locationID may be an integer
if (this.locationID === defaultValue || (defaultValue === '' && this.isDefault && $emptyOption.length === 0)) { if (String(this.locationID) === String(defaultValue) || (defaultValue === '' && this.isDefault && $emptyOption.length === 0)) {
option.attr('selected', 'selected'); option.attr('selected', 'selected');
} }
$('#pickUpLocation').append(option); $('#pickUpLocation').append(option);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment