@@ -2693,8 +2693,80 @@ class Window
26932693}
26942694
26952695/**
2696- * EventTarget is a DOM interface implemented by objects that can receive DOM events
2697- * and have listeners for them.
2696+ * An options object that specifies characteristics about the event listener.
2697+ *
2698+ * MDN
2699+ */
2700+ trait EventListenerOptions extends js.Object {
2701+
2702+ /**
2703+ * A Boolean indicating that events of this type
2704+ * will be dispatched to the registered listener
2705+ * before being dispatched to any EventTarget
2706+ * beneath it in the DOM tree.
2707+ *
2708+ * MDN
2709+ */
2710+ var capture : js.UndefOr [Boolean ] = js.undefined
2711+
2712+ /**
2713+ * A Boolean indicating that the listener
2714+ * should be invoked at most once after being added.
2715+ * If true, the listener would be automatically removed when invoked.
2716+ */
2717+ var once : js.UndefOr [Boolean ] = js.undefined
2718+
2719+ /**
2720+ * A Boolean which, if true, indicates
2721+ * that the function specified by listener
2722+ * will never call preventDefault().
2723+ * If a passive listener does call preventDefault(),
2724+ * the user agent will do nothing other
2725+ * than generate a console warning.
2726+ * See Improving scrolling performance with passive listeners to learn more.
2727+ *
2728+ * MDN
2729+ */
2730+ var passive : js.UndefOr [Boolean ] = js.undefined
2731+ }
2732+
2733+ object EventListenerOptions {
2734+
2735+ /**
2736+ * Construct a new EventListenerOptions
2737+ *
2738+ * @param capture A Boolean indicating that events of this type
2739+ * will be dispatched to the registered listener
2740+ * before being dispatched to any EventTarget
2741+ * beneath it in the DOM tree.
2742+ * @param once A Boolean indicating that the listener
2743+ * should be invoked at most once after being added.
2744+ * If true, the listener would be automatically removed when invoked.
2745+ * @param passive A Boolean which, if true, indicates
2746+ * that the function specified by listener
2747+ * will never call preventDefault().
2748+ * If a passive listener does call preventDefault(),
2749+ * the user agent will do nothing other
2750+ * than generate a console warning.
2751+ * See Improving scrolling performance with passive listeners to learn more.
2752+ * @return a new EventListenerOptions
2753+ */
2754+ def apply (capture : js.UndefOr [Boolean ] = js.undefined,
2755+ once : js.UndefOr [Boolean ] = js.undefined,
2756+ passive : js.UndefOr [Boolean ] = js.undefined): EventListenerOptions = {
2757+ val result = js.Dynamic .literal()
2758+
2759+ capture.foreach(result.capture = _)
2760+ once.foreach(result.once = _)
2761+ passive.foreach(result.passive = _)
2762+
2763+ result.asInstanceOf [EventListenerOptions ]
2764+ }
2765+ }
2766+
2767+ /**
2768+ * EventTarget is a DOM interface implemented by objects
2769+ * that can receive DOM events and have listeners for them.
26982770 *
26992771 * Element, document, and window are the most common event targets, but other
27002772 * objects can be event targets too, for example XMLHttpRequest, AudioNode,
@@ -2731,6 +2803,34 @@ class EventTarget extends js.Object {
27312803 listener : js.Function1 [T , _],
27322804 useCapture : Boolean = js.native): Unit = js.native
27332805
2806+ /**
2807+ * Removes the event listener previously registered with
2808+ * EventTarget.addEventListener.
2809+ *
2810+ * This implementation accepts a settings object of type EventListenerOptions.
2811+ *
2812+ * MDN
2813+ */
2814+ def removeEventListener [T <: Event ](`type` : String ,
2815+ listener : js.Function1 [T , _],
2816+ options : EventListenerOptions ): Unit = js.native
2817+
2818+ /**
2819+ * The EventTarget.addEventListener() method
2820+ * registers the specified listener
2821+ * on the EventTarget it's called on.
2822+ * The event target may be an Element in a document,
2823+ * the Document itself, a Window, or any other object that supports events
2824+ * (such as XMLHttpRequest).
2825+ *
2826+ * This implementation accepts a settings object of type EventListenerOptions.
2827+ *
2828+ * MDN
2829+ */
2830+ def addEventListener [T <: Event ](`type` : String ,
2831+ listener : js.Function1 [T , _],
2832+ options : EventListenerOptions ): Unit = js.native
2833+
27342834 /**
27352835 * Dispatches an Event at the specified EventTarget, invoking the affected
27362836 * EventListeners in the appropriate order. The normal event processing rules
0 commit comments