Skip to content

Commit 431b552

Browse files
committed
1 parent f97fd58 commit 431b552

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/main/scala/org/scalajs/dom/raw/lib.scala

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,6 +2701,42 @@ class Window
27012701
var lostpointercapture: js.Function1[PointerEvent, _] = js.native
27022702
}
27032703

2704+
@js.native
2705+
trait EventListenerOptions extends js.Object {
2706+
/**
2707+
* A Boolean indicating that events of this type will be dispatched to the registered
2708+
* listener before being dispatched to any EventTarget beneath it in the DOM tree.
2709+
*/
2710+
val capture: Boolean = js.native
2711+
2712+
/**
2713+
* A Boolean indicating that the listener should be invoked at most once after being added.
2714+
* If true, the listener would be automatically removed when invoked.
2715+
*/
2716+
val once: Boolean = js.native
2717+
2718+
/**
2719+
* A Boolean which, if true, indicates that the function specified by listener will
2720+
* never call preventDefault(). If a passive listener does call preventDefault(),
2721+
* the user agent will do nothing other than generate a console warning.
2722+
*/
2723+
val passive: Boolean = js.native
2724+
}
2725+
2726+
object EventListenerOptions {
2727+
def apply(capture: js.UndefOr[Boolean] = js.undefined,
2728+
once: js.UndefOr[Boolean] = js.undefined,
2729+
passive: js.UndefOr[Boolean] = js.undefined): EventListenerOptions = {
2730+
val result = js.Dynamic.literal()
2731+
2732+
capture.foreach(result.capture = _)
2733+
once.foreach(result.once = _)
2734+
passive.foreach(result.passive = _)
2735+
2736+
result.asInstanceOf[EventListenerOptions]
2737+
}
2738+
}
2739+
27042740
/**
27052741
* EventTarget is a DOM interface implemented by objects that can receive DOM events
27062742
* and have listeners for them.
@@ -2728,6 +2764,16 @@ class EventTarget extends js.Object {
27282764
listener: js.Function1[T, _],
27292765
useCapture: Boolean = js.native): Unit = js.native
27302766

2767+
/**
2768+
* Removes the event listener previously registered with
2769+
* EventTarget.addEventListener.
2770+
*
2771+
* MDN
2772+
*/
2773+
def removeEventListener[T <: Event](`type`: String,
2774+
listener: js.Function1[T, _],
2775+
options: EventListenerOptions): Unit = js.native
2776+
27312777
/**
27322778
* The EventTarget.addEventListener() method registers the specified listener on
27332779
* the EventTarget it's called on. The event target may be an Element in a document, the
@@ -2740,6 +2786,18 @@ class EventTarget extends js.Object {
27402786
listener: js.Function1[T, _],
27412787
useCapture: Boolean = js.native): Unit = js.native
27422788

2789+
/**
2790+
* The EventTarget.addEventListener() method registers the specified listener on
2791+
* the EventTarget it's called on. The event target may be an Element in a document, the
2792+
* Document itself, a Window, or any other object that supports events (such as
2793+
* XMLHttpRequest).
2794+
*
2795+
* MDN
2796+
*/
2797+
def addEventListener[T <: Event](`type`: String,
2798+
listener: js.Function1[T, _],
2799+
options: EventListenerOptions): Unit = js.native
2800+
27432801
/**
27442802
* Dispatches an Event at the specified EventTarget, invoking the affected
27452803
* EventListeners in the appropriate order. The normal event processing rules

0 commit comments

Comments
 (0)