Re: CfC: FocusEvent Interface

On Tue, Sep 22, 2009 at 9:27 PM, Doug Schepers <> wrote:
> Hi, Maciej-
> Maciej Stachowiak wrote (on 9/22/09 9:34 PM):
>> The FocusEvent interface itself seems fine, and a good solution.
> Thanks for the suggestion.  You were on the money.
>> I do think it would be worth doing some cursory research to determine
>> whether it is a problem to support "focusin" and "focusout" events
>> without 100% API compatibility with IE. Do sites only use these in
>> IE-specific code paths currently, or is it possible that they register
>> and use IE-specific APIs?
> As Garrett alluded (IIUC), they might even use the presence of these
> attributes to detect the feature for slipping into that code path.  Not a
> great practice, but there you have it (and admittedly better than browser
> sniffing).
>> These questions are relevant, because we may want to support IE's
>> toElement and fromElement attributes in the standard, depending on the
>> results.
> Sadly, I agree.
> Garrett's analysis seems pertinent here.  It would be good to research it a
> bit deeper to make sure it actually does cause the problems he described.

If there is no "onfocusin" property, and the event can only be
registered by addEventListener, then it would not break sites.

If the event can only be registered by addEventListener, then there is
a different problem. The problem that the "focusin" event listener is
not detectable. A program could not safely rely on it.

And so if the only mechanism to attach the delegating "focus" event
were through addEventListener, then a program would want to use more
widely supported approach of registering a capturing "focus" listener
and using "onfocusin" where not supported (the else clause for:-
if(el.addEventListener) {
  // capturing focus.
} else {
  // bubbling onfocusin

OTOH, if an event handler property will exist, then will it break code?

I noticed things like SimpleAjax:
        if("onfocusin" in body) {  //if IE

That would still "work" if there were no event handler property (or at
least if [[HasProperty]] returns false for "onfocusin". Then there is
the typeof checks that might make such inference. Then there are the
codes that add both onfocusin and a capturing listener (PPK code).

Inferences like that make code fragile and make the web fragile.

The jQuery validator plugin ( That one might get
away with its existing implementation and not have errors, though I
did not dig too deep (time):

The way to register delegating focus blur is to use a capturing
listener -- works in all but IE, which ahs onfocusin/onfocusout.

Onfocusin is a fine idea. The problem is with existing programs that
use poor inferences and assumptions causing compatibility issues with
this (and potentially other) new features. Proper feature detection is
a big deal.


Received on Wednesday, 23 September 2009 05:18:09 UTC