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