Skip to content

Commit 18c79ba

Browse files
committedAug 31, 2022
feat(mediaquerylist): updates MediaQueryList to extend EventTarget
1 parent b736c66 commit 18c79ba

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed
 

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,37 @@ 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,
12+
* with support for both immediate 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 */
20+
/** A string representing a serialized media query. */
2121
var 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
24+
* not the document matches the media queries in the list—changes.
25+
*
26+
* This method exists primarily for backward compatibility;
27+
* if possible, you should instead use addEventListener() to watch for the change event.
28+
* @deprecated
2529
*/
30+
@deprecated("Use addEventListener() instead")
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
34+
* changes media query status, which happens any time the document switches between matching and
35+
* not matching the media queries listed in the MediaQueryList.
36+
*
37+
* This method has been kept for backward compatibility;
38+
* if possible, you should generally use removeEventListener() to remove change notification callbacks
39+
* (which should have previously been added using addEventListener()).
40+
* @deprecated
41+
*/
42+
@deprecated("Use removeEventListener() instead")
2943
def removeListener(listener: MediaQueryListListener): Unit = js.native
3044
}

0 commit comments

Comments
 (0)
Please sign in to comment.