diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 7cc217fa3..8a85ec737 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -1856,6 +1856,7 @@ EventSource[JC] def withCredentials: Boolean EventSource[JO] val CLOSED: Int EventSource[JO] val CONNECTING: Int EventSource[JO] val OPEN: Int +EventSourceInit[JT] var withCredentials: js.UndefOr[Boolean] EventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit EventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit EventTarget[JC] def dispatchEvent(evt: Event): Boolean diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 7cc217fa3..8a85ec737 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -1856,6 +1856,7 @@ EventSource[JC] def withCredentials: Boolean EventSource[JO] val CLOSED: Int EventSource[JO] val CONNECTING: Int EventSource[JO] val OPEN: Int +EventSourceInit[JT] var withCredentials: js.UndefOr[Boolean] EventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit EventTarget[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit EventTarget[JC] def dispatchEvent(evt: Event): Boolean diff --git a/dom/src/main/scala/org/scalajs/dom/EventSource.scala b/dom/src/main/scala/org/scalajs/dom/EventSource.scala index 2d299f245..f1df885af 100644 --- a/dom/src/main/scala/org/scalajs/dom/EventSource.scala +++ b/dom/src/main/scala/org/scalajs/dom/EventSource.scala @@ -18,7 +18,9 @@ import scala.scalajs.js.annotation._ */ @js.native @JSGlobal -class EventSource(URL: String, settings: js.Dynamic = null) extends EventTarget { +class EventSource private[this] extends EventTarget { + + def this(url: String, configuration: EventSourceInit = js.native) = this() /** The url attribute must return the absolute URL that resulted from resolving the value that was passed to the * constructor. W3C 2012 diff --git a/dom/src/main/scala/org/scalajs/dom/EventSourceInit.scala b/dom/src/main/scala/org/scalajs/dom/EventSourceInit.scala new file mode 100644 index 000000000..f73c677f3 --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/EventSourceInit.scala @@ -0,0 +1,16 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** Provides options to configure the new connection. */ +trait EventSourceInit extends js.Object { + + /** defaulting to false, indicating if CORS should be set to include credentials */ + var withCredentials: js.UndefOr[Boolean] = js.undefined +}