Empty <select> causes error: 'Cannot read textContent' of undefined
JonnyBurger opened this issue · comments
Jonny Burger commented
Demo: http://codepen.io/JonnyBurger/pen/Oyerxx
element.options[element.selectedIndex].textContent;
element.selectedIndex
is -1, therefore this error happens
An empty <select>
element is seldom visible, but the error can happen even if the <select>
element is in a hidden container
Jonny Burger commented
Thank you for fixing this after 6 years! 😃 I completely forgot about opening this issue, but still a nice surprise!
Lea Verou commented
Better late than never 🤣