Skip to content

Commit e3844f6

Browse files
committed
1 parent f97fd58 commit e3844f6

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

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

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

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

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

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

0 commit comments

Comments
 (0)