Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#14686 closed bug (fixed)

val() throws invalid argument in Internet Explorer 10-11

Reported by: RoBorg@… 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 6 years ago by markelog

Component: unfiledattributes
Priority: undecidedlow

Confirmed, but only for 1.x, also reproducible for IE10 – http://jsfiddle.net/2avmY/

comment:2 Changed 6 years ago by markelog

Summary: val() throws invalid argument in Internet Explorer 11val() throws invalid argument in Internet Explorer 10-11

comment:3 Changed 6 years ago by markelog

Owner: set to markelog
Status: newassigned

comment:4 Changed 6 years ago by dmethvin

Milestone: None1.11/2.1
Resolution: fixed
Status: assignedclosed

comment:5 Changed 6 years ago by dmethvin

Followup in #14858

comment:6 Changed 6 years ago by John Hoven

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 5 years ago by cmorris

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

Note: See TracTickets for help on using tickets.