diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 9a4935c94..6d633f76b 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -15450,11 +15450,16 @@ MediaList[JC] def item(index: Int): String MediaList[JC] def length: Int MediaList[JC] def mediaText: String MediaList[JC] @scala.scalajs.js.annotation.JSBracketAccess def update(index: Int, v: String): Unit -MediaQueryList[JT] def addListener(listener: MediaQueryListListener): Unit +MediaQueryList[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +MediaQueryList[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +MediaQueryList[JT] def addListener(listener: MediaQueryListListener): Unit (@deprecated in 2.4.0) +MediaQueryList[JT] def dispatchEvent(evt: Event): Boolean MediaQueryList[JT] def matches: Boolean -MediaQueryList[JT] var media: String -MediaQueryList[JT] def removeListener(listener: MediaQueryListListener): Unit -MediaQueryListListener[JT] def apply(mql: MediaQueryList): Unit +MediaQueryList[JT] def media: String +MediaQueryList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +MediaQueryList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +MediaQueryList[JT] def removeListener(listener: MediaQueryListListener): Unit (@deprecated in 2.4.0) +MediaQueryListListener[JT] def apply(mql: MediaQueryList): Unit (@deprecated in 2.4.0) MediaSource[JC] def activeSourceBuffers: SourceBufferList MediaSource[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit MediaSource[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 9a4935c94..6d633f76b 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -15450,11 +15450,16 @@ MediaList[JC] def item(index: Int): String MediaList[JC] def length: Int MediaList[JC] def mediaText: String MediaList[JC] @scala.scalajs.js.annotation.JSBracketAccess def update(index: Int, v: String): Unit -MediaQueryList[JT] def addListener(listener: MediaQueryListListener): Unit +MediaQueryList[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +MediaQueryList[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +MediaQueryList[JT] def addListener(listener: MediaQueryListListener): Unit (@deprecated in 2.4.0) +MediaQueryList[JT] def dispatchEvent(evt: Event): Boolean MediaQueryList[JT] def matches: Boolean -MediaQueryList[JT] var media: String -MediaQueryList[JT] def removeListener(listener: MediaQueryListListener): Unit -MediaQueryListListener[JT] def apply(mql: MediaQueryList): Unit +MediaQueryList[JT] def media: String +MediaQueryList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +MediaQueryList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +MediaQueryList[JT] def removeListener(listener: MediaQueryListListener): Unit (@deprecated in 2.4.0) +MediaQueryListListener[JT] def apply(mql: MediaQueryList): Unit (@deprecated in 2.4.0) MediaSource[JC] def activeSourceBuffers: SourceBufferList MediaSource[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit MediaSource[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit diff --git a/dom/src/main/scala/org/scalajs/dom/MediaQueryList.scala b/dom/src/main/scala/org/scalajs/dom/MediaQueryList.scala index ddf389133..79fc3a9c3 100644 --- a/dom/src/main/scala/org/scalajs/dom/MediaQueryList.scala +++ b/dom/src/main/scala/org/scalajs/dom/MediaQueryList.scala @@ -8,23 +8,36 @@ package org.scalajs.dom import scala.scalajs.js -/** A MediaQueryList object maintains a list of media queries on a document, and handles sending notifications to - * listeners when the media queries on the document change. +/** A MediaQueryList object stores information on a media query applied to a document, with support for both immediate + * and event-driven matching against the state of the document. */ @js.native -trait MediaQueryList extends js.Object { +trait MediaQueryList extends EventTarget { - /** true if the document currently matches the media query list; otherwise false. Read only. */ + /** A boolean value that returns true if the document currently matches the media query list, or false if not. */ def matches: Boolean = js.native - /** The serialized media query list */ - var media: String = js.native + /** A string representing a serialized media query. */ + def media: String = js.native - /** Adds a new listener to the media query list. If the specified listener is already in the list, this method has no - * effect. + /** Adds to the MediaQueryList a callback which is invoked whenever the media query status—whether or not the document + * matches the media queries in the list—changes. + * + * This method exists primarily for backward compatibility; if possible, you should instead use addEventListener() to + * watch for the change event. + * @deprecated */ + @deprecated("Use addEventListener() instead", "2.4.0") def addListener(listener: MediaQueryListListener): Unit = js.native - /** Removes a listener from the media query list. Does nothing if the specified listener isn't already in the list. */ + /** Removes the specified listener callback from the callbacks to be invoked when the MediaQueryList changes media + * query status, which happens any time the document switches between matching and not matching the media queries + * listed in the MediaQueryList. + * + * This method has been kept for backward compatibility; if possible, you should generally use removeEventListener() + * to remove change notification callbacks (which should have previously been added using addEventListener()). + * @deprecated + */ + @deprecated("Use removeEventListener() instead", "2.4.0") def removeListener(listener: MediaQueryListListener): Unit = js.native } diff --git a/dom/src/main/scala/org/scalajs/dom/MediaQueryListListener.scala b/dom/src/main/scala/org/scalajs/dom/MediaQueryListListener.scala index c46867533..0914c4c91 100644 --- a/dom/src/main/scala/org/scalajs/dom/MediaQueryListListener.scala +++ b/dom/src/main/scala/org/scalajs/dom/MediaQueryListListener.scala @@ -8,10 +8,8 @@ package org.scalajs.dom import scala.scalajs.js -/** A MediaQueryList object maintains a list of media queries on a document, and handles sending notifications to - * listeners when the media queries on the document change. - */ @js.native +@deprecated("See MediaQueryList for more info", "2.4.0") trait MediaQueryListListener extends js.Object { def apply(mql: MediaQueryList): Unit = js.native }