Skip to content

Migrate DOMParser to dom #566

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 1 commit into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
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
18 changes: 10 additions & 8 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ DOMList[SO] def hasNext: Boolean
DOMList[SO] def iterator: Iterator[T]
DOMList[SO] def length: Int
DOMList[SO] def next(): T
DOMParser[JC] def parseFromString(source: String, mimeType: String): Document
DOMParser[JC] def parseFromString(string: String, mimeType: MIMEType): Document
DOMRect[JC] var bottom: Double
DOMRect[JC] var height: Double
DOMRect[JC] var left: Double
Expand Down Expand Up @@ -14165,6 +14165,12 @@ Location[JT] var protocol: String
Location[JT] def reload(flag: Boolean?): Unit
Location[JT] def replace(url: String): Unit
Location[JT] var search: String
MIMEType[JT]
MIMEType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[MIMEType]
MIMEType[SO] val `application/xml` = "application/xml".asInstanceOf[MIMEType]
MIMEType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[MIMEType]
MIMEType[SO] val `text/html` = "text/html".asInstanceOf[MIMEType]
MIMEType[SO] val `text/xml` = "text/xml".asInstanceOf[MIMEType]
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
MediaElementAudioSourceNode[JT] var channelCount: Int
Expand Down Expand Up @@ -24389,13 +24395,9 @@ experimental/deviceorientation/DeviceOrientationEventInit[JT] var scoped: js.Und
experimental/deviceorientation/DeviceRotationRate[JT] val alpha: Double
experimental/deviceorientation/DeviceRotationRate[JT] val beta: Double
experimental/deviceorientation/DeviceRotationRate[JT] val gamma: Double
experimental/domparser/DOMParser[JC] def parseFromString(string: String, supportedType: SupportedType): Document
experimental/domparser/SupportedType[JT]
experimental/domparser/SupportedType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[SupportedType]
experimental/domparser/SupportedType[SO] val `application/xml` = "application/xml".asInstanceOf[SupportedType]
experimental/domparser/SupportedType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[SupportedType]
experimental/domparser/SupportedType[SO] val `text/html` = "text/html".asInstanceOf[SupportedType]
experimental/domparser/SupportedType[SO] val `text/xml` = "text/xml".asInstanceOf[SupportedType]
experimental/domparser/package[SO] type DOMParser = dom.DOMParser (@deprecated in 2.0.0)
experimental/domparser/package[SO] type SupportedType = dom.MIMEType (@deprecated in 2.0.0)
experimental/domparser/package[SO] @deprecated("use dom.MIMEType instead", "2.0.0") val SupportedType = dom.MIMEType
experimental/gamepad/Gamepad[JT] val axes: js.Array[Double]
experimental/gamepad/Gamepad[JT] val buttons: js.Array[GamepadButton]
experimental/gamepad/Gamepad[JT] val connected: Boolean
Expand Down
18 changes: 10 additions & 8 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ DOMList[SO] def hasNext: Boolean
DOMList[SO] def iterator: Iterator[T]
DOMList[SO] def length: Int
DOMList[SO] def next(): T
DOMParser[JC] def parseFromString(source: String, mimeType: String): Document
DOMParser[JC] def parseFromString(string: String, mimeType: MIMEType): Document
DOMRect[JC] var bottom: Double
DOMRect[JC] var height: Double
DOMRect[JC] var left: Double
Expand Down Expand Up @@ -14165,6 +14165,12 @@ Location[JT] var protocol: String
Location[JT] def reload(flag: Boolean?): Unit
Location[JT] def replace(url: String): Unit
Location[JT] var search: String
MIMEType[JT]
MIMEType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[MIMEType]
MIMEType[SO] val `application/xml` = "application/xml".asInstanceOf[MIMEType]
MIMEType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[MIMEType]
MIMEType[SO] val `text/html` = "text/html".asInstanceOf[MIMEType]
MIMEType[SO] val `text/xml` = "text/xml".asInstanceOf[MIMEType]
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
MediaElementAudioSourceNode[JT] var channelCount: Int
Expand Down Expand Up @@ -24389,13 +24395,9 @@ experimental/deviceorientation/DeviceOrientationEventInit[JT] var scoped: js.Und
experimental/deviceorientation/DeviceRotationRate[JT] val alpha: Double
experimental/deviceorientation/DeviceRotationRate[JT] val beta: Double
experimental/deviceorientation/DeviceRotationRate[JT] val gamma: Double
experimental/domparser/DOMParser[JC] def parseFromString(string: String, supportedType: SupportedType): Document
experimental/domparser/SupportedType[JT]
experimental/domparser/SupportedType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[SupportedType]
experimental/domparser/SupportedType[SO] val `application/xml` = "application/xml".asInstanceOf[SupportedType]
experimental/domparser/SupportedType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[SupportedType]
experimental/domparser/SupportedType[SO] val `text/html` = "text/html".asInstanceOf[SupportedType]
experimental/domparser/SupportedType[SO] val `text/xml` = "text/xml".asInstanceOf[SupportedType]
experimental/domparser/package[SO] type DOMParser = dom.DOMParser (@deprecated in 2.0.0)
experimental/domparser/package[SO] type SupportedType = dom.MIMEType (@deprecated in 2.0.0)
experimental/domparser/package[SO] @deprecated("use dom.MIMEType instead", "2.0.0") val SupportedType = dom.MIMEType
experimental/gamepad/Gamepad[JT] val axes: js.Array[Double]
experimental/gamepad/Gamepad[JT] val buttons: js.Array[GamepadButton]
experimental/gamepad/Gamepad[JT] val connected: Boolean
Expand Down
41 changes: 41 additions & 0 deletions src/main/scala/org/scalajs/dom/DOMParser.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.annotation._

/** The [[DOMParser]] interface provides the ability to parse XML or HTML source code from a string into a DOM Document.
*
* You can perform the opposite operation—converting a DOM tree into XML or HTML source—using the `XMLSerializer`
* interface.
*
* In the case of an HTML document, you can also replace portions of the DOM with new DOM trees built from HTML by
* setting the value of the `Element.innerHTML` and `outerHTML` properties. These properties can also be read to fetch
* HTML fragments corresponding to the corresponding DOM subtree.
*
* Note that `XMLHttpRequest` can parse XML and HTML directly from a URL-addressable resource, returning a Document in
* its response property.
*/
@js.native
@JSGlobal
class DOMParser extends js.Object {

/** The DOMParser can also be used to parse a SVG document or a HTML document. There are three different results
* possible, selected by the MIME type given. If the MIME type is text/xml, the resulting object will be an
* XMLDocument, if the MIME type is image/svg+xml, it will be an SVGDocument and if the MIME type is text/html, it
* will be an HTMLDocument.
*/
def parseFromString(string: String, mimeType: MIMEType): Document = js.native
}

@js.native
sealed trait MIMEType extends js.Any

object MIMEType {
val `text/html` = "text/html".asInstanceOf[MIMEType]
val `text/xml` = "text/xml".asInstanceOf[MIMEType]
val `application/xml` = "application/xml".asInstanceOf[MIMEType]

val `application/xhtml+xml` =
"application/xhtml+xml".asInstanceOf[MIMEType]
val `image/svg+xml` = "image/svg+xml".asInstanceOf[MIMEType]
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.scalajs
package dom.experimental

package object domparser {

@deprecated("use dom.DOMParser instead", "2.0.0")
type DOMParser = dom.DOMParser

@deprecated("use dom.MIMEType instead", "2.0.0")
type SupportedType = dom.MIMEType

@deprecated("use dom.MIMEType instead", "2.0.0")
val SupportedType = dom.MIMEType
}
11 changes: 0 additions & 11 deletions src/main/scala/org/scalajs/dom/lib.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3844,17 +3844,6 @@ trait Position extends js.Object {
@JSGlobal
class PerformanceMark extends PerformanceEntry

/** DOMParser can parse XML or HTML source stored in a string into a DOM Document. DOMParser is specified in DOM Parsing
* and Serialization.
*
* Note that XMLHttpRequest supports parsing XML and HTML from URL-addressable resources.
*/
@js.native
@JSGlobal
class DOMParser extends js.Object {
def parseFromString(source: String, mimeType: String): Document = js.native
}

/** An object implementing the StyleSheet interface represents a single style sheet. CSS style sheets will further
* implement the more specialized CSSStyleSheet interface.
*/
Expand Down