Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates MediaQueryList to extend EventTarget #724

Merged
merged 7 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 22 additions & 9 deletions dom/src/main/scala/org/scalajs/dom/MediaQueryList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}