Skip to content

Add EventSourceInit #703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion dom/src/main/scala/org/scalajs/dom/EventSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/EventSourceInit.scala
Original file line number Diff line number Diff line change
@@ -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
}