@@ -2701,6 +2701,43 @@ class Window
2701
2701
var lostpointercapture : js.Function1 [PointerEvent , _] = js.native
2702
2702
}
2703
2703
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
+
2704
2741
/**
2705
2742
* EventTarget is a DOM interface implemented by objects that can receive DOM events
2706
2743
* and have listeners for them.
@@ -2728,6 +2765,16 @@ class EventTarget extends js.Object {
2728
2765
listener : js.Function1 [T , _],
2729
2766
useCapture : Boolean = js.native): Unit = js.native
2730
2767
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
+
2731
2778
/**
2732
2779
* The EventTarget.addEventListener() method registers the specified listener on
2733
2780
* 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 {
2740
2787
listener : js.Function1 [T , _],
2741
2788
useCapture : Boolean = js.native): Unit = js.native
2742
2789
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
+
2743
2802
/**
2744
2803
* Dispatches an Event at the specified EventTarget, invoking the affected
2745
2804
* EventListeners in the appropriate order. The normal event processing rules
0 commit comments