Skip to content

Add URL.searchParams (URLSearch​Params) #361

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 2 commits into from
May 14, 2019
Merged
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
48 changes: 48 additions & 0 deletions src/main/scala/org/scalajs/dom/experimental/URL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,52 @@ class URL(url: String, base: String = js.native) extends js.Object {
* MDN
*/
var hash: String = js.native

var searchParams: URLSearchParams = js.native
}

/**
* The URLSearchParams defines utility methods to work with the query string of a URL.
*
* MDN
*/
@js.native
@JSGlobal
class URLSearchParams
extends js.Iterable[js.Tuple2[String, String]] {

/**
* Leading '?' characters are ignored.
*
* MDN
*/
def this(init: String) = this()
def this(init: Sequence[String]) = this()
def this(init: js.Dictionary[String]) = this()

def append(name: String, value: String): Unit = js.native

def delete(name: String): Unit = js.native

def get(name: String): js.UndefOr[String] = js.native

def getAll(name: String): Sequence[String] = js.native

def has(name: String): Boolean = js.native

def set(name: String, value: String): Unit = js.native

def sort(): Unit = js.native

@JSName(js.Symbol.iterator)
override def jsIterator(): js.Iterator[js.Tuple2[String, String]] = js.native

def entries(): js.Iterator[js.Tuple2[String, String]] = js.native

def keys(): js.Iterator[String] = js.native

def values(): js.Iterator[String] = js.native

def forEach(callback: js.Function2[String, String, Unit]): Unit = js.native

}