Skip to content

Commit 8266cde

Browse files
authored
Merge pull request #724 from mabasic/feature/mediaquerylist
Updates MediaQueryList to extend EventTarget
2 parents b736c66 + 3b55eeb commit 8266cde

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

api-reports/2_12.txt

+9-4
Original file line numberDiff line numberDiff line change
@@ -15450,11 +15450,16 @@ MediaList[JC] def item(index: Int): String
1545015450
MediaList[JC] def length: Int
1545115451
MediaList[JC] def mediaText: String
1545215452
MediaList[JC] @scala.scalajs.js.annotation.JSBracketAccess def update(index: Int, v: String): Unit
15453-
MediaQueryList[JT] def addListener(listener: MediaQueryListListener): Unit
15453+
MediaQueryList[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
15454+
MediaQueryList[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
15455+
MediaQueryList[JT] def addListener(listener: MediaQueryListListener): Unit (@deprecated in 2.4.0)
15456+
MediaQueryList[JT] def dispatchEvent(evt: Event): Boolean
1545415457
MediaQueryList[JT] def matches: Boolean
15455-
MediaQueryList[JT] var media: String
15456-
MediaQueryList[JT] def removeListener(listener: MediaQueryListListener): Unit
15457-
MediaQueryListListener[JT] def apply(mql: MediaQueryList): Unit
15458+
MediaQueryList[JT] def media: String
15459+
MediaQueryList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
15460+
MediaQueryList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
15461+
MediaQueryList[JT] def removeListener(listener: MediaQueryListListener): Unit (@deprecated in 2.4.0)
15462+
MediaQueryListListener[JT] def apply(mql: MediaQueryList): Unit (@deprecated in 2.4.0)
1545815463
MediaSource[JC] def activeSourceBuffers: SourceBufferList
1545915464
MediaSource[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
1546015465
MediaSource[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit

api-reports/2_13.txt

+9-4
Original file line numberDiff line numberDiff line change
@@ -15450,11 +15450,16 @@ MediaList[JC] def item(index: Int): String
1545015450
MediaList[JC] def length: Int
1545115451
MediaList[JC] def mediaText: String
1545215452
MediaList[JC] @scala.scalajs.js.annotation.JSBracketAccess def update(index: Int, v: String): Unit
15453-
MediaQueryList[JT] def addListener(listener: MediaQueryListListener): Unit
15453+
MediaQueryList[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
15454+
MediaQueryList[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
15455+
MediaQueryList[JT] def addListener(listener: MediaQueryListListener): Unit (@deprecated in 2.4.0)
15456+
MediaQueryList[JT] def dispatchEvent(evt: Event): Boolean
1545415457
MediaQueryList[JT] def matches: Boolean
15455-
MediaQueryList[JT] var media: String
15456-
MediaQueryList[JT] def removeListener(listener: MediaQueryListListener): Unit
15457-
MediaQueryListListener[JT] def apply(mql: MediaQueryList): Unit
15458+
MediaQueryList[JT] def media: String
15459+
MediaQueryList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
15460+
MediaQueryList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
15461+
MediaQueryList[JT] def removeListener(listener: MediaQueryListListener): Unit (@deprecated in 2.4.0)
15462+
MediaQueryListListener[JT] def apply(mql: MediaQueryList): Unit (@deprecated in 2.4.0)
1545815463
MediaSource[JC] def activeSourceBuffers: SourceBufferList
1545915464
MediaSource[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
1546015465
MediaSource[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit

dom/src/main/scala/org/scalajs/dom/MediaQueryList.scala

+22-9
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,36 @@ package org.scalajs.dom
88

99
import scala.scalajs.js
1010

11-
/** A MediaQueryList object maintains a list of media queries on a document, and handles sending notifications to
12-
* listeners when the media queries on the document change.
11+
/** A MediaQueryList object stores information on a media query applied to a document, with support for both immediate
12+
* and event-driven matching against the state of the document.
1313
*/
1414
@js.native
15-
trait MediaQueryList extends js.Object {
15+
trait MediaQueryList extends EventTarget {
1616

17-
/** true if the document currently matches the media query list; otherwise false. Read only. */
17+
/** A boolean value that returns true if the document currently matches the media query list, or false if not. */
1818
def matches: Boolean = js.native
1919

20-
/** The serialized media query list */
21-
var media: String = js.native
20+
/** A string representing a serialized media query. */
21+
def media: String = js.native
2222

23-
/** Adds a new listener to the media query list. If the specified listener is already in the list, this method has no
24-
* effect.
23+
/** Adds to the MediaQueryList a callback which is invoked whenever the media query status—whether or not the document
24+
* matches the media queries in the list—changes.
25+
*
26+
* This method exists primarily for backward compatibility; if possible, you should instead use addEventListener() to
27+
* watch for the change event.
28+
* @deprecated
2529
*/
30+
@deprecated("Use addEventListener() instead", "2.4.0")
2631
def addListener(listener: MediaQueryListListener): Unit = js.native
2732

28-
/** Removes a listener from the media query list. Does nothing if the specified listener isn't already in the list. */
33+
/** Removes the specified listener callback from the callbacks to be invoked when the MediaQueryList changes media
34+
* query status, which happens any time the document switches between matching and not matching the media queries
35+
* listed in the MediaQueryList.
36+
*
37+
* This method has been kept for backward compatibility; if possible, you should generally use removeEventListener()
38+
* to remove change notification callbacks (which should have previously been added using addEventListener()).
39+
* @deprecated
40+
*/
41+
@deprecated("Use removeEventListener() instead", "2.4.0")
2942
def removeListener(listener: MediaQueryListListener): Unit = js.native
3043
}

dom/src/main/scala/org/scalajs/dom/MediaQueryListListener.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ package org.scalajs.dom
88

99
import scala.scalajs.js
1010

11-
/** A MediaQueryList object maintains a list of media queries on a document, and handles sending notifications to
12-
* listeners when the media queries on the document change.
13-
*/
1411
@js.native
12+
@deprecated("See MediaQueryList for more info", "2.4.0")
1513
trait MediaQueryListListener extends js.Object {
1614
def apply(mql: MediaQueryList): Unit = js.native
1715
}

0 commit comments

Comments
 (0)