Skip to content

Commit c1afb38

Browse files
committed
Migrate DOMParser to dom
1 parent 432af50 commit c1afb38

File tree

6 files changed

+75
-58
lines changed

6 files changed

+75
-58
lines changed

api-reports/2_12.txt

+10-8
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ DOMList[SO] def hasNext: Boolean
11321132
DOMList[SO] def iterator: Iterator[T]
11331133
DOMList[SO] def length: Int
11341134
DOMList[SO] def next(): T
1135-
DOMParser[JC] def parseFromString(source: String, mimeType: String): Document
1135+
DOMParser[JC] def parseFromString(string: String, mimeType: MIMEType): Document
11361136
DOMRect[JC] var bottom: Double
11371137
DOMRect[JC] var height: Double
11381138
DOMRect[JC] var left: Double
@@ -14165,6 +14165,12 @@ Location[JT] var protocol: String
1416514165
Location[JT] def reload(flag: Boolean?): Unit
1416614166
Location[JT] def replace(url: String): Unit
1416714167
Location[JT] var search: String
14168+
MIMEType[JT]
14169+
MIMEType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[MIMEType]
14170+
MIMEType[SO] val `application/xml` = "application/xml".asInstanceOf[MIMEType]
14171+
MIMEType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[MIMEType]
14172+
MIMEType[SO] val `text/html` = "text/html".asInstanceOf[MIMEType]
14173+
MIMEType[SO] val `text/xml` = "text/xml".asInstanceOf[MIMEType]
1416814174
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
1416914175
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
1417014176
MediaElementAudioSourceNode[JT] var channelCount: Int
@@ -24389,13 +24395,9 @@ experimental/deviceorientation/DeviceOrientationEventInit[JT] var scoped: js.Und
2438924395
experimental/deviceorientation/DeviceRotationRate[JT] val alpha: Double
2439024396
experimental/deviceorientation/DeviceRotationRate[JT] val beta: Double
2439124397
experimental/deviceorientation/DeviceRotationRate[JT] val gamma: Double
24392-
experimental/domparser/DOMParser[JC] def parseFromString(string: String, supportedType: SupportedType): Document
24393-
experimental/domparser/SupportedType[JT]
24394-
experimental/domparser/SupportedType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[SupportedType]
24395-
experimental/domparser/SupportedType[SO] val `application/xml` = "application/xml".asInstanceOf[SupportedType]
24396-
experimental/domparser/SupportedType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[SupportedType]
24397-
experimental/domparser/SupportedType[SO] val `text/html` = "text/html".asInstanceOf[SupportedType]
24398-
experimental/domparser/SupportedType[SO] val `text/xml` = "text/xml".asInstanceOf[SupportedType]
24398+
experimental/domparser/package[SO] type DOMParser = dom.DOMParser (@deprecated in 2.0.0)
24399+
experimental/domparser/package[SO] type SupportedType = dom.MIMEType (@deprecated in 2.0.0)
24400+
experimental/domparser/package[SO] @deprecated("use dom.MIMEType instead", "2.0.0") val SupportedType = dom.MIMEType
2439924401
experimental/gamepad/Gamepad[JT] val axes: js.Array[Double]
2440024402
experimental/gamepad/Gamepad[JT] val buttons: js.Array[GamepadButton]
2440124403
experimental/gamepad/Gamepad[JT] val connected: Boolean

api-reports/2_13.txt

+10-8
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ DOMList[SO] def hasNext: Boolean
11321132
DOMList[SO] def iterator: Iterator[T]
11331133
DOMList[SO] def length: Int
11341134
DOMList[SO] def next(): T
1135-
DOMParser[JC] def parseFromString(source: String, mimeType: String): Document
1135+
DOMParser[JC] def parseFromString(string: String, mimeType: MIMEType): Document
11361136
DOMRect[JC] var bottom: Double
11371137
DOMRect[JC] var height: Double
11381138
DOMRect[JC] var left: Double
@@ -14165,6 +14165,12 @@ Location[JT] var protocol: String
1416514165
Location[JT] def reload(flag: Boolean?): Unit
1416614166
Location[JT] def replace(url: String): Unit
1416714167
Location[JT] var search: String
14168+
MIMEType[JT]
14169+
MIMEType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[MIMEType]
14170+
MIMEType[SO] val `application/xml` = "application/xml".asInstanceOf[MIMEType]
14171+
MIMEType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[MIMEType]
14172+
MIMEType[SO] val `text/html` = "text/html".asInstanceOf[MIMEType]
14173+
MIMEType[SO] val `text/xml` = "text/xml".asInstanceOf[MIMEType]
1416814174
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
1416914175
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
1417014176
MediaElementAudioSourceNode[JT] var channelCount: Int
@@ -24389,13 +24395,9 @@ experimental/deviceorientation/DeviceOrientationEventInit[JT] var scoped: js.Und
2438924395
experimental/deviceorientation/DeviceRotationRate[JT] val alpha: Double
2439024396
experimental/deviceorientation/DeviceRotationRate[JT] val beta: Double
2439124397
experimental/deviceorientation/DeviceRotationRate[JT] val gamma: Double
24392-
experimental/domparser/DOMParser[JC] def parseFromString(string: String, supportedType: SupportedType): Document
24393-
experimental/domparser/SupportedType[JT]
24394-
experimental/domparser/SupportedType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[SupportedType]
24395-
experimental/domparser/SupportedType[SO] val `application/xml` = "application/xml".asInstanceOf[SupportedType]
24396-
experimental/domparser/SupportedType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[SupportedType]
24397-
experimental/domparser/SupportedType[SO] val `text/html` = "text/html".asInstanceOf[SupportedType]
24398-
experimental/domparser/SupportedType[SO] val `text/xml` = "text/xml".asInstanceOf[SupportedType]
24398+
experimental/domparser/package[SO] type DOMParser = dom.DOMParser (@deprecated in 2.0.0)
24399+
experimental/domparser/package[SO] type SupportedType = dom.MIMEType (@deprecated in 2.0.0)
24400+
experimental/domparser/package[SO] @deprecated("use dom.MIMEType instead", "2.0.0") val SupportedType = dom.MIMEType
2439924401
experimental/gamepad/Gamepad[JT] val axes: js.Array[Double]
2440024402
experimental/gamepad/Gamepad[JT] val buttons: js.Array[GamepadButton]
2440124403
experimental/gamepad/Gamepad[JT] val connected: Boolean
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.scalajs.dom
2+
3+
import scala.scalajs.js
4+
import scala.scalajs.js.annotation._
5+
6+
/** The [[DOMParser]] interface provides the ability to parse XML or HTML source code from a string into a DOM Document.
7+
*
8+
* You can perform the opposite operation—converting a DOM tree into XML or HTML source—using the `XMLSerializer`
9+
* interface.
10+
*
11+
* In the case of an HTML document, you can also replace portions of the DOM with new DOM trees built from HTML by
12+
* setting the value of the `Element.innerHTML` and `outerHTML` properties. These properties can also be read to fetch
13+
* HTML fragments corresponding to the corresponding DOM subtree.
14+
*
15+
* Note that `XMLHttpRequest` can parse XML and HTML directly from a URL-addressable resource, returning a Document in
16+
* its response property.
17+
*/
18+
@js.native
19+
@JSGlobal
20+
class DOMParser extends js.Object {
21+
22+
/** The DOMParser can also be used to parse a SVG document or a HTML document. There are three different results
23+
* possible, selected by the MIME type given. If the MIME type is text/xml, the resulting object will be an
24+
* XMLDocument, if the MIME type is image/svg+xml, it will be an SVGDocument and if the MIME type is text/html, it
25+
* will be an HTMLDocument.
26+
*/
27+
def parseFromString(string: String, mimeType: MIMEType): Document = js.native
28+
}
29+
30+
@js.native
31+
sealed trait MIMEType extends js.Any
32+
33+
object MIMEType {
34+
val `text/html` = "text/html".asInstanceOf[MIMEType]
35+
val `text/xml` = "text/xml".asInstanceOf[MIMEType]
36+
val `application/xml` = "application/xml".asInstanceOf[MIMEType]
37+
38+
val `application/xhtml+xml` =
39+
"application/xhtml+xml".asInstanceOf[MIMEType]
40+
val `image/svg+xml` = "image/svg+xml".asInstanceOf[MIMEType]
41+
}

src/main/scala/org/scalajs/dom/experimental/domparser/DOMParser.scala

-31
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.scalajs
2+
package dom.experimental
3+
4+
package object domparser {
5+
6+
@deprecated("use dom.DOMParser instead", "2.0.0")
7+
type DOMParser = dom.DOMParser
8+
9+
@deprecated("use dom.MIMEType instead", "2.0.0")
10+
type SupportedType = dom.MIMEType
11+
12+
@deprecated("use dom.MIMEType instead", "2.0.0")
13+
val SupportedType = dom.MIMEType
14+
}

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

-11
Original file line numberDiff line numberDiff line change
@@ -3844,17 +3844,6 @@ trait Position extends js.Object {
38443844
@JSGlobal
38453845
class PerformanceMark extends PerformanceEntry
38463846

3847-
/** DOMParser can parse XML or HTML source stored in a string into a DOM Document. DOMParser is specified in DOM Parsing
3848-
* and Serialization.
3849-
*
3850-
* Note that XMLHttpRequest supports parsing XML and HTML from URL-addressable resources.
3851-
*/
3852-
@js.native
3853-
@JSGlobal
3854-
class DOMParser extends js.Object {
3855-
def parseFromString(source: String, mimeType: String): Document = js.native
3856-
}
3857-
38583847
/** An object implementing the StyleSheet interface represents a single style sheet. CSS style sheets will further
38593848
* implement the more specialized CSSStyleSheet interface.
38603849
*/

0 commit comments

Comments
 (0)