Skip to main content

Bug Tracker

Side navigation

#14686 closed bug (fixed)

Opened January 10, 2014 03:40PM UTC

Closed March 20, 2014 07:12PM UTC

Last modified September 19, 2014 06:34PM UTC

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

Reported by: RoBorg@hotmail.com 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();
Attachments (0)
Change History (7)

Changed January 12, 2014 07:39PM UTC by markelog comment:1

component: unfiledattributes
priority: undecidedlow

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

Changed January 12, 2014 07:40PM UTC by markelog comment:2

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

Changed January 12, 2014 08:50PM UTC by markelog comment:3

owner: → markelog
status: newassigned

Changed March 20, 2014 07:12PM UTC by dmethvin comment:4

milestone: None1.11/2.1
resolution: → fixed
status: assignedclosed

Changed March 20, 2014 07:13PM UTC by dmethvin comment:5

Followup in #14858

Changed March 20, 2014 07:56PM UTC by John Hoven comment:6

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

Changed September 19, 2014 06:34PM UTC by cmorris comment:7

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