-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Description
I have a select element that contains options whose values contain tab characters. My original use case was a trailing tab (string\t), but I've also tested with leading tabs (\tstring) and tabs in the middle of non-whitespace (str\ting).
I called .val('value with tab') on the select element and expected the corresponding option to be selected since the values are identical, but no option is selected.
A few interesting observations:
- I can work around this issue for the leading and trailing cases by removing the leading or trailing tab characters from the string I pass to
.val(), but this is unexpected since the values don't match exactly. - Removing a middle tab character and passing that to
.val()does not select the value, so there is no workaround for strings that have tab characters in the middle. - The behavior is the same with jquery 2.2.1, 3.0.0-alpha1 and edge.
- With jquery 1.12.1, the leading and trailing tabs have the bug behavior but having a tab in the middle of the word and passing a matching string with a tab in the middle works as expected, so there was a regression at some point in this case.
JSFiddle: https://jsfiddle.net/onnucjx7/2/ You'll see in the console what I expect the behavior to be compared to what the behavior actually is.
I searched for "tab" and "whitespace" and didn't see anything directly relevant; I did find this issue #1902 but it only mentions IE10 and I am seeing the unexpected behavior in Firefox 44 and Chrome 48.