Skip to content

Updates MediaQueryList to extend EventTarget #724

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

Merged
merged 7 commits into from
Sep 5, 2022
Merged
Changes from 1 commit
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
Next Next commit
feat(mediaquerylist): updates MediaQueryList to extend EventTarget
  • Loading branch information
mabasic committed Aug 31, 2022
commit 18c79bae028c53dac2da1983e8eb650f125eb0b4
30 changes: 22 additions & 8 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,37 @@ 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 */
/** A string representing a serialized media query. */
var 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")
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")
def removeListener(listener: MediaQueryListListener): Unit = js.native
}