Skip to content

Commit

Permalink
Add Protections to FIx Potential JS Bug
Browse files Browse the repository at this point in the history
If the searchbox is empty and the search button is clicked, it could
throw a JS error.
  • Loading branch information
Kelderic committed Jan 30, 2018
1 parent aba9073 commit 68b1aab
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/mapstractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,14 @@
// AN OPTION FROM THE AUTOCOMPLETE SUGGESTIONS)IS CLICKED

self.searchBox.addListener('places_changed', function() {
var places = self.searchBox.getPlaces();
if ( places ) {
var place = places[0];
searchInputElement.value = place.formatted_address;
placefoundCallback(place);
self.searchBox.current = place;
if ( searchInputElement.value.replace( ' ', '' ) ) {
var places = self.searchBox.getPlaces();
if ( places && places.length > 0 ) {
var place = places[0];
searchInputElement.value = place.formatted_address;
placefoundCallback(place);
self.searchBox.current = place;
}
}
});

Expand Down

0 comments on commit 68b1aab

Please sign in to comment.