Skip to content

Commit bf1c5a1

Browse files
authored
Fix setPlaceholder not returning the updated placeholder string (#502)
1 parent 056c09c commit bf1c5a1

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## HEAD
22

3+
## 5.0.2
4+
5+
### Bug fixes 🐛
6+
7+
- Fix `setPlaceholder` so that when `setPlaceholder` is called afterwards it return updated placeholder string [#502](https://github.com/mapbox/mapbox-gl-geocoder/pull/502)
8+
39
## 5.0.1
410

511
### Bug fixes 🐛

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,9 +1058,9 @@ MapboxGeocoder.prototype = {
10581058
* @returns {MapboxGeocoder} this
10591059
*/
10601060
setPlaceholder: function(placeholder){
1061-
this.placeholder = (placeholder) ? placeholder : this._getPlaceholderText();
1062-
this._inputEl.placeholder = this.placeholder;
1063-
this._inputEl.setAttribute('aria-label', this.placeholder);
1061+
this.options.placeholder = (placeholder) ? placeholder : this._getPlaceholderText();
1062+
this._inputEl.placeholder = this.options.placeholder;
1063+
this._inputEl.setAttribute('aria-label', this.options.placeholder);
10641064
return this
10651065
},
10661066

test/test.geocoder.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ test('geocoder', function(tt) {
959959
t.equals(geocoder._inputEl.placeholder, 'Test', 'the right placeholder is set on initialization');
960960
geocoder.setPlaceholder('Search');
961961
t.equals(geocoder._inputEl.placeholder, 'Search', 'the placeholder was changed in the UI element');
962+
t.equals(geocoder.getPlaceholder(), 'Search', 'the placeholder returned from getPlaceholder is the right value');
962963
t.end();
963964
});
964965

0 commit comments

Comments
 (0)