Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
#27
Browse files Browse the repository at this point in the history
we can’t easily detect if a page is loading from the browser history buttons, so opt to not keep the cached values of selects
  • Loading branch information
pryley committed Aug 14, 2018
1 parent 6dcf585 commit be39832
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/float-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,10 @@
setSelectPlaceholder: function( el, placeholderText ) {
var childEl = el.firstElementChild;
if( childEl.hasAttribute( 'value' ) && childEl.value ) {
var selected = el.options[Math.max( 0, el.selectedIndex )].defaultSelected !== true ? true : false;
el.insertBefore( new Option( placeholderText, '', selected, selected ), childEl );
el.insertBefore( new Option( placeholderText, '' ), childEl );
if( el.options[el.selectedIndex].defaultSelected === false ) {
el.selectedIndex = 0;
}
}
else {
childEl.setAttribute( 'value', '' );
Expand Down

0 comments on commit be39832

Please sign in to comment.