Safari Developer Library

Developer

SafariEvent Class Reference

Options
Deployment Target:

On This Page

SafariEvent

The SafariEvent class is a base class used to encapsulate events. Developers who are familiar with DOM events will notice many similarities in design and behavior.

Events are sent to their target and its ancestors in three phases. In order, they are as follows:

  1. Capturing. The event is sent to every ancestor of the its target, starting with the most distant ancestor, and ending with the parent of the event’s target.

  2. Targeting. The event is sent to its target.

  3. Bubbling. The event is sent to every ancestor of its target, starting with the parent of the event’s target, and ending with its most distant ancestor.

You can tell which phase an event is in from the value of its eventPhase property. When you register for an event notification, you specify whether or not you want to be notified during the capturing phase. Therefore, you may not always need to check what phase the event is in.

  • type Property

    The type of the event.

    Declaration

    readonly attribute DOMString type

    Discussion

    The string used to identify a particular type of event is documented in the reference for that class.

  • target Property

    The target of the event.

    Declaration

    readonly attribute SafariEventTarget target

    Discussion

    This attribute stays the same as the event moves through the event-dispatch hierarchy. Its value is the same as the object that the event is sent to during the targeting phase.

  • The object that the event is currently being sent to.

    Declaration

    readonly attribute SafariEventTarget currentTarget

    Discussion

    This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy.

  • timeStamp Property

    The time and date that the event was created.

    Declaration

    readonly attribute DOMTimeStamp timeStamp

  • eventPhase Property

    The event-handling phase that the event is in.

    Declaration

    readonly attribute unsigned short eventPhase

    Discussion

    The values for this property are the same as the values used by Webkit to identify the event-handling phases. See Event-Handling Phases.

  • bubbles Property

    A Boolean value that indicates whether the event goes through the bubbling phase.

    Declaration

    readonly attribute boolean bubbles

  • cancelable Property

    A Boolean value that indicates whether the event can be canceled.

    Declaration

    readonly attribute boolean cancelable

    See Also

    stopPropagation

  • Prevents the event from any further propagation.

    Declaration

    void stopPropagation ()

    Discussion

    Propagation can be stopped only fon cancelable events. After propagation is stopped, the event is not sent to any other targets.

    See Also

    cancelable

  • Prevents the browser from performing the default action for an event.

    Declaration

    void preventDefault ()

    Discussion

    Use this method to indicate that your extension has already fully handled the event; you don’t want the browser to do anything. Note that preventing the default action does not stop an event from propagating.

  • A Boolean value that indicates whether the event’s default action has been prevented.

    Declaration

    readonly attribute boolean defaultPrevented

Constants

  • Phases of the event-handling process.

    Declaration

    Constants

    • CAPTURING_PHASE

      The capturing phase.

    • TARGETING_PHASE

      The targeting phase.

    • BUBBLING_PHASE

      The bubbling phase.