Skip to content

Commit eb09404

Browse files
authored
Merge pull request #458 from sjrd/cleanups
Cleanups, part 1
2 parents 159bab0 + a327899 commit eb09404

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+49277
-48825
lines changed

api-reports/2_12.txt

Lines changed: 23858 additions & 23809 deletions
Large diffs are not rendered by default.

api-reports/2_13.txt

Lines changed: 23858 additions & 23809 deletions
Large diffs are not rendered by default.

example/src/main/scala/example/Example.scala

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package example
22

3+
import scala.scalajs.js
34
import scala.scalajs.js.annotation._
45

56
import org.scalajs.dom
@@ -125,21 +126,25 @@ object EventHandler{
125126
}
126127
}
127128

128-
@JSExportTopLevel("ExampleXMLHttpRequest")
129-
object XMLHttpRequest{
129+
@JSExportTopLevel("ExampleFetch")
130+
object Fetch {
130131
@JSExport
131132
def main(pre: html.Pre) = {
132-
val xhr = new dom.XMLHttpRequest()
133-
xhr.open("GET",
133+
import scala.concurrent
134+
.ExecutionContext
135+
.Implicits
136+
.global
137+
import js.Thenable.Implicits._
138+
val url =
134139
"https://www.boredapi.com/api/activity"
135-
)
136-
xhr.onload = { (e: dom.Event) =>
137-
if (xhr.status == 200) {
138-
pre.textContent =
139-
xhr.responseText
140-
}
140+
val responseText = for {
141+
response <- dom.fetch(url)
142+
text <- response.text()
143+
} yield {
144+
text
141145
}
142-
xhr.send()
146+
for (text <- responseText)
147+
pre.textContent = text
143148
}
144149
}
145150

@@ -162,20 +167,3 @@ object Websocket {
162167
}
163168
}
164169
}
165-
166-
@JSExportTopLevel("ExampleAjaxExtension")
167-
object AjaxExtension {
168-
@JSExport
169-
def main(pre: html.Pre) = {
170-
import dom.ext.Ajax
171-
import scala.concurrent
172-
.ExecutionContext
173-
.Implicits
174-
.global
175-
val url =
176-
"https://www.boredapi.com/api/activity"
177-
Ajax.get(url).foreach { case xhr =>
178-
pre.textContent = xhr.responseText
179-
}
180-
}
181-
}

readme/Index.scalatex

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@
115115
autorun=true
116116
)
117117

118-
@sect{dom.XMLHttpRequest}
118+
@sect{dom.Fetch}
119119
@pair(
120-
"XMLHttpRequest",
120+
"Fetch",
121121
Seq(
122122
pre("output")
123123
)
@@ -145,38 +145,19 @@
145145
@li
146146
Deprecated properties/methods/types will not be present.
147147
@li
148-
IE-only, Chrome-only, FF-only, and in general browser-specific attributes will only be found under the @hl.scala{experimental} package.
148+
IE-only, Chrome-only, FF-only, and in general browser-specific attributes will typically not be present.
149149
@li
150150
The name of a Scala type should map directly to the name of the corresponding Javascript type.
151151
@li
152152
Any type which is a Javascript type (e.g. you can @hl.scala{instanceof} in javascript) should be a Scala @hl.scala{class}; any other interface which isn't a Javascript type should be a @hl.scala{trait}.
153153
@li
154154
Read-only members should be @hl.scala{def}, and not-directly-instantiable classes should have @hl.scala{private} constructors.
155155

156-
@sect{Extensions}
157-
158-
@p
159-
Apart from @hl.scala{Color}, Scala-js-dom contains some useful helpers and implicit classes in @hl.scala{org.scalajs.dom.ext} that serve no purpose other than to make your use of the DOM more pleasant.
160-
161-
@p
162-
Examples include the @hl.scala{Ajax.get} and @hl.scala{Ajax.post} methods which let you avoid messing with @hl.scala{dom.XMLHttpRequest} directly, or @hl.scala{KeyCodes} which provides a nice list of the keycodes that result from pressing various keys on the keyboard.
163-
@pair(
164-
"AjaxExtension",
165-
Seq(
166-
pre("output")
167-
)
168-
)
169-
170-
@p
171-
See also @a("roll", href:="https://github.com/lihaoyi/roll") (@a("live demo", href:="http://lihaoyi.github.io/roll/")) and @a("scala-js-games", href:="https://github.com/lihaoyi/scala-js-games") for an example of its use. @a("Scala-js-fiddle", href:="http://www.scala-js-fiddle.com/") also contains a pile of @a("fun examples", href:="(http://www.scala-js-fiddle.com/gist/9405209/Oscilloscope.scala") that demonstrate its usage. Pull requests/forks are welcome!
172-
173156
@sect{Contributing}
174157
@p
175-
Scala-js-dom is a work in progress. The current code base is a hodgepodge of auto-generated/scraped/hand-tweaked code, and is full of rough edges. If you see something that you think can be improved, feel free to send a pull request. These could include:
158+
The DOM API is always evolving, and scala-js-dom is a hodgepodge of auto-generated/scraped/hand-tweaked code full of rough edges. If you see something that you think can be improved, feel free to send a pull request. These could include:
176159
@ul
177160
@li
178161
Improved doc-comments; who doesn't love better docs?
179162
@li
180163
Missing methods/properties/classes; send the PR adding it in including it together with a link to an authoritative source (e.g. MDN) and it should get merged.
181-
@li
182-
Additional extensions (in @hl.scala{org.scalajs.dom.ext}). These currently represent an arbitrary collection of helpers that have been needed so far. If there's some implicit that you find you need and you think other people will to, send a pull request and we can talk about it.

src/main/scala-new-collections/org/scalajs/dom/ext/NamedNodeMapMap.scala renamed to src/main/scala-new-collections/org/scalajs/dom/NamedNodeMapMap.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
package org.scalajs.dom.ext
1+
package org.scalajs.dom
22

3-
import org.scalajs.dom._
43
import scala.collection.mutable
54

6-
class NamedNodeMapMap private[ext] (namedNodeMap: NamedNodeMap)
5+
private[dom] class NamedNodeMapMap(namedNodeMap: NamedNodeMap)
76
extends mutable.Map[String, Attr] {
87
self =>
98

src/main/scala-old-collections/org/scalajs/dom/ext/NamedNodeMapMap.scala renamed to src/main/scala-old-collections/org/scalajs/dom/NamedNodeMapMap.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
package org.scalajs.dom.ext
1+
package org.scalajs.dom
22

3-
import org.scalajs.dom._
43
import scala.collection.mutable
54

6-
class NamedNodeMapMap private[ext] (namedNodeMap: NamedNodeMap)
5+
private[dom] class NamedNodeMapMap(namedNodeMap: NamedNodeMap)
76
extends mutable.Map[String, Attr] {
87
self =>
98

src/main/scala/org/scalajs/dom/experimental/AbortController.scala renamed to src/main/scala/org/scalajs/dom/AbortController.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
package org.scalajs.dom.experimental
1+
package org.scalajs.dom
22

3-
import org.scalajs.dom.raw.EventTarget
43
import scala.scalajs.js
54
import scala.scalajs.js.annotation.JSGlobal
65

src/main/scala/org/scalajs/dom/raw/Audio.scala renamed to src/main/scala/org/scalajs/dom/Audio.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Everything else is under the MIT License
88
* http://opensource.org/licenses/MIT
99
*/
10-
package org.scalajs.dom.raw
10+
package org.scalajs.dom
1111

1212
import org.scalajs.dom.experimental.mediastream.MediaStream
1313
import scala.scalajs.js

src/main/scala/org/scalajs/dom/raw/Css.scala renamed to src/main/scala/org/scalajs/dom/CSSTypes.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Everything else is under the MIT License
88
* http://opensource.org/licenses/MIT
99
*/
10-
package org.scalajs.dom.raw
10+
package org.scalajs.dom
1111

1212
import scala.scalajs.js
1313
import scala.scalajs.js.annotation._
@@ -501,7 +501,9 @@ class CSSPageRule extends CSSRule {
501501
*/
502502
@js.native
503503
@JSGlobal
504-
class CSSRuleList extends DOMList[CSSRule]
504+
class CSSRuleList private[this] () extends DOMList[CSSRule] {
505+
def item(index: Int): CSSRule = js.native
506+
}
505507

506508
/**
507509
* The CSSKeyframesRule interface describes an object representing a complete set
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.scalajs.dom
2+
3+
import org.scalajs.dom
4+
5+
/**
6+
* Short aliases of all the dom.CSSThing classes
7+
*/
8+
@deprecated("directly use the dom.CSS* types and values instead", "2.0.0")
9+
object DeprecatedCSSAliases {
10+
@deprecated("use dom.CSS instead", "2.0.0")
11+
@inline def CSS = dom.CSS
12+
@deprecated("use dom.FontFaceRule instead", "2.0.0")
13+
type FontFaceRule = CSSFontFaceRule
14+
@deprecated("use dom.ImportRule instead", "2.0.0")
15+
type ImportRule = CSSImportRule
16+
@deprecated("use dom.KeyframeRule instead", "2.0.0")
17+
type KeyframeRule = CSSKeyframeRule
18+
@deprecated("use dom.MediaRule instead", "2.0.0")
19+
type MediaRule = CSSMediaRule
20+
@deprecated("use dom.NamespaceRule instead", "2.0.0")
21+
type NamespaceRule = CSSNamespaceRule
22+
@deprecated("use dom.PageRule instead", "2.0.0")
23+
type PageRule = CSSPageRule
24+
@deprecated("use dom.Rule instead", "2.0.0")
25+
type Rule = CSSRule
26+
@deprecated("use dom.Rule instead", "2.0.0")
27+
@inline def Rule = CSSRule
28+
@deprecated("use dom.RuleList instead", "2.0.0")
29+
type RuleList = CSSRuleList
30+
@deprecated("use dom.StyleDeclaration instead", "2.0.0")
31+
type StyleDeclaration = CSSStyleDeclaration
32+
@deprecated("use dom.StyleSheet instead", "2.0.0")
33+
type StyleSheet = CSSStyleSheet
34+
@deprecated("use dom.StyleRule instead", "2.0.0")
35+
type StyleRule = CSSStyleRule
36+
}

0 commit comments

Comments
 (0)