Skip to content

Commit 883d3d9

Browse files
authored
Merge pull request #703 from scala-js/feature/event-source-init
Add `EventSourceInit`
2 parents b2bbc9d + e725f1a commit 883d3d9

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

api-reports/2_12.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,7 @@ EventSource[JC] def withCredentials: Boolean
18561856
EventSource[JO] val CLOSED: Int
18571857
EventSource[JO] val CONNECTING: Int
18581858
EventSource[JO] val OPEN: Int
1859+
EventSourceInit[JT] var withCredentials: js.UndefOr[Boolean]
18591860
EventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
18601861
EventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
18611862
EventTarget[JC] def dispatchEvent(evt: Event): Boolean

api-reports/2_13.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,7 @@ EventSource[JC] def withCredentials: Boolean
18561856
EventSource[JO] val CLOSED: Int
18571857
EventSource[JO] val CONNECTING: Int
18581858
EventSource[JO] val OPEN: Int
1859+
EventSourceInit[JT] var withCredentials: js.UndefOr[Boolean]
18591860
EventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
18601861
EventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
18611862
EventTarget[JC] def dispatchEvent(evt: Event): Boolean

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import scala.scalajs.js.annotation._
1818
*/
1919
@js.native
2020
@JSGlobal
21-
class EventSource(URL: String, settings: js.Dynamic = null) extends EventTarget {
21+
class EventSource private[this] extends EventTarget {
22+
23+
def this(url: String, configuration: EventSourceInit = js.native) = this()
2224

2325
/** The url attribute must return the absolute URL that resulted from resolving the value that was passed to the
2426
* constructor. W3C 2012
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API
2+
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later.
3+
* http://creativecommons.org/licenses/by-sa/2.5/
4+
*
5+
* Everything else is under the MIT License http://opensource.org/licenses/MIT
6+
*/
7+
package org.scalajs.dom
8+
9+
import scala.scalajs.js
10+
11+
/** Provides options to configure the new connection. */
12+
trait EventSourceInit extends js.Object {
13+
14+
/** defaulting to false, indicating if CORS should be set to include credentials */
15+
var withCredentials: js.UndefOr[Boolean] = js.undefined
16+
}

0 commit comments

Comments
 (0)