Skip to main content

Bug Tracker

Side navigation

#13026 closed bug (cantfix)

Opened December 10, 2012 04:05PM UTC

Closed December 11, 2012 02:46PM UTC

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

Reported by: contact@adamlynch.ie 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.

Attachments (0)
Change History (1)

Changed December 11, 2012 02:46PM UTC by dmethvin comment:1

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.