Skip to content

Commit

Permalink
Merge pull request #724 from mabasic/feature/mediaquerylist
Browse files Browse the repository at this point in the history
Updates MediaQueryList to extend EventTarget
  • Loading branch information
armanbilge authored Sep 5, 2022
2 parents b736c66 + 3b55eeb commit 8266cde
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
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
}

0 comments on commit 8266cde

Please sign in to comment.