#14686 closed bug (fixed)
val() throws invalid argument in Internet Explorer 10-11
Reported by: | Owned by: | markelog | |
---|---|---|---|
Priority: | low | Milestone: | 1.11/2.1 |
Component: | attributes | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
The .val() method can throw an invalid argument exception when trying to retrieve the value in IE 11. This is really an IE bug, not a jQuery bug, but it would be nice if jQuery could work around it.
The following code doesn't work in IE 11:
var x = $('<option/>'); x.val(); // This throws an exception
The root cause is this:
var e = document.createElement('option'); e.text; // This throws an exception
For anyone looking for a workaround, if you add a value attribute, then .text won't be read, e.g.
var x = $('<option value=""/>'); x.val();
Change History (7)
comment:1 Changed 9 years ago by
Component: | unfiled → attributes |
---|---|
Priority: | undecided → low |
comment:2 Changed 9 years ago by
Summary: | val() throws invalid argument in Internet Explorer 11 → val() throws invalid argument in Internet Explorer 10-11 |
---|
comment:3 Changed 9 years ago by
Owner: | set to markelog |
---|---|
Status: | new → assigned |
comment:4 Changed 9 years ago by
Milestone: | None → 1.11/2.1 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
comment:6 Changed 9 years ago by
Attributes: Trim whitespace from option text when returned as a value
Fixes #14858 Ref #14686 Closes gh-1531 (cherry picked from commit 9ec429cf6270e455aba4eba85f4db80e633806b6)
Conflicts:
src/attributes/val.js
Changeset: 541e7349b6533eb533c15d17e3e9e432e4a719ea
comment:7 Changed 8 years ago by
Just a quick note to say that the underlying issue in IE has been fixed and will be released with the next major release. No specific timing to share yet, but news will be released via the IE Blog or @IEDevChat.
-Charles
Confirmed, but only for 1.x, also reproducible for IE10 – http://jsfiddle.net/2avmY/