Skip to content

Commit d4dfe6a

Browse files
authored
Merge pull request #566 from scala-js/topic/migrate-domparser
Migrate DOMParser to dom
2 parents 23aef73 + c1afb38 commit d4dfe6a

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
@@ -1130,7 +1130,7 @@ DOMList[SO] def hasNext: Boolean
11301130
DOMList[SO] def iterator: Iterator[T]
11311131
DOMList[SO] def length: Int
11321132
DOMList[SO] def next(): T
1133-
DOMParser[JC] def parseFromString(source: String, mimeType: String): Document
1133+
DOMParser[JC] def parseFromString(string: String, mimeType: MIMEType): Document
11341134
DOMRect[JC] var bottom: Double
11351135
DOMRect[JC] var height: Double
11361136
DOMRect[JC] var left: Double
@@ -14163,6 +14163,12 @@ Location[JT] var protocol: String
1416314163
Location[JT] def reload(flag: Boolean?): Unit
1416414164
Location[JT] def replace(url: String): Unit
1416514165
Location[JT] var search: String
14166+
MIMEType[JT]
14167+
MIMEType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[MIMEType]
14168+
MIMEType[SO] val `application/xml` = "application/xml".asInstanceOf[MIMEType]
14169+
MIMEType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[MIMEType]
14170+
MIMEType[SO] val `text/html` = "text/html".asInstanceOf[MIMEType]
14171+
MIMEType[SO] val `text/xml` = "text/xml".asInstanceOf[MIMEType]
1416614172
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
1416714173
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
1416814174
MediaElementAudioSourceNode[JT] var channelCount: Int
@@ -24387,13 +24393,9 @@ experimental/deviceorientation/DeviceOrientationEventInit[JT] var scoped: js.Und
2438724393
experimental/deviceorientation/DeviceRotationRate[JT] val alpha: Double
2438824394
experimental/deviceorientation/DeviceRotationRate[JT] val beta: Double
2438924395
experimental/deviceorientation/DeviceRotationRate[JT] val gamma: Double
24390-
experimental/domparser/DOMParser[JC] def parseFromString(string: String, supportedType: SupportedType): Document
24391-
experimental/domparser/SupportedType[JT]
24392-
experimental/domparser/SupportedType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[SupportedType]
24393-
experimental/domparser/SupportedType[SO] val `application/xml` = "application/xml".asInstanceOf[SupportedType]
24394-
experimental/domparser/SupportedType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[SupportedType]
24395-
experimental/domparser/SupportedType[SO] val `text/html` = "text/html".asInstanceOf[SupportedType]
24396-
experimental/domparser/SupportedType[SO] val `text/xml` = "text/xml".asInstanceOf[SupportedType]
24396+
experimental/domparser/package[SO] type DOMParser = dom.DOMParser (@deprecated in 2.0.0)
24397+
experimental/domparser/package[SO] type SupportedType = dom.MIMEType (@deprecated in 2.0.0)
24398+
experimental/domparser/package[SO] @deprecated("use dom.MIMEType instead", "2.0.0") val SupportedType = dom.MIMEType
2439724399
experimental/gamepad/Gamepad[JT] val axes: js.Array[Double]
2439824400
experimental/gamepad/Gamepad[JT] val buttons: js.Array[GamepadButton]
2439924401
experimental/gamepad/Gamepad[JT] val connected: Boolean

api-reports/2_13.txt

+10-8
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ DOMList[SO] def hasNext: Boolean
11301130
DOMList[SO] def iterator: Iterator[T]
11311131
DOMList[SO] def length: Int
11321132
DOMList[SO] def next(): T
1133-
DOMParser[JC] def parseFromString(source: String, mimeType: String): Document
1133+
DOMParser[JC] def parseFromString(string: String, mimeType: MIMEType): Document
11341134
DOMRect[JC] var bottom: Double
11351135
DOMRect[JC] var height: Double
11361136
DOMRect[JC] var left: Double
@@ -14163,6 +14163,12 @@ Location[JT] var protocol: String
1416314163
Location[JT] def reload(flag: Boolean?): Unit
1416414164
Location[JT] def replace(url: String): Unit
1416514165
Location[JT] var search: String
14166+
MIMEType[JT]
14167+
MIMEType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[MIMEType]
14168+
MIMEType[SO] val `application/xml` = "application/xml".asInstanceOf[MIMEType]
14169+
MIMEType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[MIMEType]
14170+
MIMEType[SO] val `text/html` = "text/html".asInstanceOf[MIMEType]
14171+
MIMEType[SO] val `text/xml` = "text/xml".asInstanceOf[MIMEType]
1416614172
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
1416714173
MediaElementAudioSourceNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
1416814174
MediaElementAudioSourceNode[JT] var channelCount: Int
@@ -24387,13 +24393,9 @@ experimental/deviceorientation/DeviceOrientationEventInit[JT] var scoped: js.Und
2438724393
experimental/deviceorientation/DeviceRotationRate[JT] val alpha: Double
2438824394
experimental/deviceorientation/DeviceRotationRate[JT] val beta: Double
2438924395
experimental/deviceorientation/DeviceRotationRate[JT] val gamma: Double
24390-
experimental/domparser/DOMParser[JC] def parseFromString(string: String, supportedType: SupportedType): Document
24391-
experimental/domparser/SupportedType[JT]
24392-
experimental/domparser/SupportedType[SO] val `application/xhtml+xml` = "application/xhtml+xml".asInstanceOf[SupportedType]
24393-
experimental/domparser/SupportedType[SO] val `application/xml` = "application/xml".asInstanceOf[SupportedType]
24394-
experimental/domparser/SupportedType[SO] val `image/svg+xml` = "image/svg+xml".asInstanceOf[SupportedType]
24395-
experimental/domparser/SupportedType[SO] val `text/html` = "text/html".asInstanceOf[SupportedType]
24396-
experimental/domparser/SupportedType[SO] val `text/xml` = "text/xml".asInstanceOf[SupportedType]
24396+
experimental/domparser/package[SO] type DOMParser = dom.DOMParser (@deprecated in 2.0.0)
24397+
experimental/domparser/package[SO] type SupportedType = dom.MIMEType (@deprecated in 2.0.0)
24398+
experimental/domparser/package[SO] @deprecated("use dom.MIMEType instead", "2.0.0") val SupportedType = dom.MIMEType
2439724399
experimental/gamepad/Gamepad[JT] val axes: js.Array[Double]
2439824400
experimental/gamepad/Gamepad[JT] val buttons: js.Array[GamepadButton]
2439924401
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
@@ -3847,17 +3847,6 @@ trait Position extends js.Object {
38473847
@JSGlobal
38483848
class PerformanceMark extends PerformanceEntry
38493849

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

0 commit comments

Comments
 (0)