1. Introduction
1.1. Overview
TODO.
1.2. Conformance
Boilerplate?
2. Stylistic Conventions
This specification follows the Proposed W3C Specification Conventions, with the following supplemental additions:
This is a note.
This is an open issue.
This is a warning.
interface Example { // This is an IDL definition. };
3. Focus Events
This interface and its associated event types and § 3.2 Focus Event Order were designed in accordance to the concepts and guidelines defined in User Agent Accessibility Guidelines 2.0 [UAAG20], with particular attention on the focus mechanism and the terms defined in the glossary entry for focus.
3.1. Interface FocusEvent
Introduced in this specification
The FocusEvent
interface provides specific contextual information
associated with Focus events.
To create an instance of the FocusEvent
interface, use the
FocusEvent constructor, passing an optional FocusEventInit
dictionary.
3.1.1. FocusEvent
[Exposed =Window ]interface :
FocusEvent UIEvent {(
constructor DOMString ,
type optional FocusEventInit = {});
eventInitDict readonly attribute EventTarget ?; };
relatedTarget
FocusEvent . relatedTarget
-
Used to identify a secondary
EventTarget
related to a Focus event, depending on the type of event.For security reasons with nested browsing contexts, when tabbing into or out of a nested context, the relevant
EventTarget
SHOULD benull
.The un-initialized value of this attribute MUST be
null
.
3.1.2. FocusEventInit
dictionary :
FocusEventInit UIEventInit {EventTarget ?=
relatedTarget null ; };
FocusEventInit . relatedTarget
- The
relatedTarget
should be initialized to the element losing focus (in the case of afocus
orfocusin
event) or the element gaining focus (in the case of ablur
orfocusout
event).
3.2. Focus Event Order
The focus events defined in this specification occur in a set order relative to one another. The following is the typical sequence of events when a focus is shifted between elements (this order assumes that no element is initially focused):
Event Type | Notes | |
---|---|---|
User shifts focus | ||
1 | focus
| Sent after first target element receives focus |
2 | focusin
| Follows the focus event |
User shifts focus | ||
3 | blur
| Sent after first target element loses focus |
4 | focusout
| Follows the blur event |
5 | focus
| Sent after second target element receives focus |
6 | focusin
| Follows the focus event |
This specification does not define the behavior of focus events when
interacting with methods such as focus()
or blur()
. See the relevant specifications where those methods
are defined for such behavior.
3.3. Document Focus and Focus Context
This event module includes event types for notification of changes in document focus. There are three distinct focus contexts that are relevant to this discussion:
-
The operating system focus context which MAY be on one of many different applications currently running on the computer. One of these applications with focus can be a browser.
-
When the browser has focus, the user can switch (such as with the tab key) the application focus context among the different browser user interface fields (e.g., the Web site location bar, a search field, etc.). One of these user interface fields can be the document being shown in a tab.
-
When the document itself has focus, the document focus context can be set to any of the focusable elements in the document.
The event types defined in this specification deal exclusively with document focus, and the event target identified in the event details MUST only be part of the document or documents in the window, never a part of the browser or operating system, even when switching from one focus context to another.
Normally, a document always has a focused element (even if it is the document element itself) and a persistent focus ring. When switching between focus contexts, the document’s currently focused element and focus ring normally remain in their current state. For example, if a document has three focusable elements, with the second element focused, when a user changes operating system focus to another application and then back to the browser, the second element will still be focused within the document, and tabbing will change the focus to the third element. A host language MAY define specific elements which might receive focus, the conditions under which an element MAY receive focus, the means by which focus MAY be changed, and the order in which the focus changes. For example, in some cases an element might be given focus by moving a pointer over it, while other circumstances might require a mouse click. Some elements might not be focusable at all, and some might be focusable only by special means (clicking on the element), but not by tabbing to it. Documents MAY contain multiple focus rings. Other specifications MAY define a more complex focus model than is described in this specification, including allowing multiple elements to have the current focus.
3.4. Focus Event Types
The Focus event types are listed below.
3.4.1. blur
Type | blur
|
---|---|
Interface | FocusEvent
|
Sync / Async | Sync |
Bubbles | No |
Trusted Targets | Window , Element
|
Cancelable | No |
Composed | Yes |
Default action | None |
Context (trusted events) |
|
A user agent MUST dispatch this event when an event target loses focus. The focus MUST be taken from the element before the dispatch of this event type. This event type is similar to focusout, but does not bubble.
3.4.2. focus
Type | focus
|
---|---|
Interface | FocusEvent
|
Sync / Async | Sync |
Bubbles | No |
Trusted Targets | Window , Element
|
Cancelable | No |
Composed | Yes |
Default action | None |
Context (trusted events) |
|
A user agent MUST dispatch this event when an event target receives focus. The focus MUST be given to the element before the dispatch of this event type. This event type is similar to focusin, but does not bubble.
3.4.3. focusin
Type | focusin
|
---|---|
Interface | FocusEvent
|
Sync / Async | Sync |
Bubbles | Yes |
Trusted Targets | Window , Element
|
Cancelable | No |
Composed | Yes |
Default action | None |
Context (trusted events) |
|
A user agent MUST dispatch this event when an event target receives focus. The event target MUST be the element which received focus. The focus event MUST fire before the dispatch of this event type. This event type is similar to focus, but does bubble.
3.4.4. focusout
Type | focusout
|
---|---|
Interface | FocusEvent
|
Sync / Async | Sync |
Bubbles | Yes |
Trusted Targets | Window , Element
|
Cancelable | No |
Composed | Yes |
Default action | None |
Context (trusted events) |
|
A user agent MUST dispatch this event when an event target loses focus. The event target MUST be the element which lost focus. The blur event MUST fire before the dispatch of this event type. This event type is similar to blur, but does bubble.
4. Legacy FocusEvent
events
4.1. Legacy FocusEvent
event types
4.1.1. DOMFocusIn
Type | DOMFocusIn
|
---|---|
Interface | FocusEvent
|
Sync / Async | Sync |
Bubbles | Yes |
Trusted Targets | Window , Element
|
Cancelable | No |
Composed | Yes |
Default action | None |
Context (trusted events) |
|
A user agent MUST dispatch this event when an event
target receives focus. The focus MUST be given to the
element before the dispatch of this event type. This event type
MUST be dispatched after the event type focus
.
The DOMFocusIn
event type is defined in this
specification for reference and completeness, but this
specification deprecates the use of this event type in
favor of the related event types focus
and focusin
.
4.1.2. DOMFocusOut
Type | DOMFocusOut
|
---|---|
Interface | FocusEvent
|
Sync / Async | Sync |
Bubbles | Yes |
Trusted Targets | Window , Element
|
Cancelable | No |
Composed | Yes |
Default action | None |
Context (trusted events) |
|
A user agent MUST dispatch this event when an event
target loses focus. The focus MUST be taken from the element
before the dispatch of this event type. This event type MUST be
dispatched after the event type blur
.
The DOMFocusOut
event type is defined in this
specification for reference and completeness, but this
specification deprecates the use of this event type in
favor of the related event types blur
and focusout
.
4.2. Legacy FocusEvent event order
The following is the typical sequence of events when a focus is shifted
between elements, including the deprecated DOMFocusIn
and DOMFocusOut
events. The order shown assumes that no element is
initially focused.
Event Type | Notes | |
---|---|---|
User shifts focus | ||
1 | focusin
| Sent before first target element receives focus |
2 | focus
| Sent after first target element receives focus |
3 | DOMFocusIn
| If supported |
User shifts focus | ||
4 | focusout
| Sent before first target element loses focus |
5 | focusin
| Sent before second target element receives focus |
6 | blur
| Sent after first target element loses focus |
7 | DOMFocusOut
| If supported |
8 | focus
| Sent after second target element receives focus |
9 | DOMFocusIn
| If supported |
5. Security Considerations
TODO - Add specific concerns for this spec
6. Acknowledgements
TODO
7. Refs to other UIEvent specs [DELETE]
This section will be deleted.
Temporary place to "define" other referenced UI Events (to make the bikeshed linker happy). This will be deleted once we have proper cross-references.
7.1. Things defined in other sections
7.1.1. Activation triggers and behavior
7.1.2. Composition Events
7.1.3. Default actions and cancelable events
7.1.4. Event dispatch and DOM event flow
7.1.5. Web browsers and other dynamic or interactive user agents
7.1.6. Authoring tools
8. Glossary [DELETE]
This section will be deleted.
Temporary glossary terms (for bikeshed linker). Many of these are properly defined elsewhere and should be linked to directly. Terms which should be defined in this spec should be defined inline.
- event
-
An event is the representation of some occurrence (such as a mouse click on the presentation of an element, the removal of child node from an element, or any number of other possibilities) which is associated with its event target. Each event is an instantiation of one specific event type.
- event focus
-
Event focus is a special state of receptivity and concentration on a particular element or other event target within a document. Each element has different behavior when focused, depending on its functionality, such as priming the element for activation (as for a button or hyperlink) or toggling state (as for a checkbox), receiving text input (as for a text form field), or copying selected text. For more details, see § 3.3 Document Focus and Focus Context.
- event target
-
The object to which an event is targeted using the § 7.1.4 Event dispatch and DOM event flow. The event target is the value of the
target
attribute. - event focus ring
-
An event focus ring is an ordered set of event focus targets within a document. A host language MAY define one or more ways to determine the order of targets, such as document order, a numerical index defined per focus target, explicit pointers between focus targets, or a hybrid of different models. Each document MAY contain multiple focus rings, or conditional focus rings. Typically, for document-order or indexed focus rings, focus
wraps around
from the last focus target to the first. - host language
-
Any language which integrates the features of another language or API specification, while normatively referencing the origin specification rather than redefining those features, and extending those features only in ways defined by the origin specification. An origin specification typically is only intended to be implemented in the context of one or more host languages, not as a standalone language. For example, XHTML, HTML, and SVG are host languages for UI Events, and they integrate and extend the objects and models defined in this specification.
- un-initialized value
-
The value of any event attribute (such as
bubbles
orcurrentTarget
) before the event has been initialized withinitEvent()
. The un-initialized values of an event apply immediately after a new event has been created using the methodcreateEvent()
. - user agent
-
A program, such as a browser or content authoring tool, normally running on a client machine, which acts on a user’s behalf in retrieving, interpreting, executing, presenting, or creating content. Users MAY act on the content using different user agents at different times, for different purposes. See the § 7.1.5 Web browsers and other dynamic or interactive user agents and § 7.1.6 Authoring tools for details on the requirements for a conforming user agent.
- Window
-
The
Window
is the object referred to by the current document’s browsing context’s Window Proxy object as defined in HTML5 [HTML5].