Bug Tracker

Opened 7 years ago

Closed 7 years ago

#13026 closed bug (cantfix)

.focus() on disabled input inside try causes issues (IE8)

Reported by: contact@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.3
Keywords: Cc:
Blocked by: Blocking:

Description

Version: 1.7.2 - 1.8.3 (didn't test any lower).

On IE8 (latest Chrome & Firefox are fine), if you try to focus on a disabled input but catch it in a try-catch, then it has an impact outside of the try-catch. In my case, I noticed that the placeholder polyfill function wasn't working correctly (click inside the input and the placeholder should disappear).

JSFiddle example: http://jsfiddle.net/57wgy/14/

Blurring the element in the catch works: http://jsfiddle.net/57wgy/11/ (but why should we have to?)

Context: I wanted to store whether or not the browser could focus on disabled inputs in $.support, and maybe even extend $.fn.focus to evaluate this new property of $.support before actually trying to focus on the element (if it's disabled). (This might actually be what jQuery does anyway, I'm not sure).

Nevertheless, I think it's unexpected behaviour.

Change History (1)

comment:1 Changed 7 years ago by dmethvin

Resolution: cantfix
Status: newclosed

The problem is that IE fires focus and blur asynchronously. We can't work around that from the jQuery core level. You'll need to track whether the element is disabled and avoid trying to focus it. Although other browsers may not throw an error when you set focus to a disabled or hidden element, it doesn't make logical sense to do so anyway.

See also #12161 and #10345.

Note: See TracTickets for help on using tickets.