-
Notifications
You must be signed in to change notification settings - Fork 161
Fix #219: Fix Event constructors. #367
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
Conversation
@@ -29,23 +28,23 @@ class DeviceOrientationEvent( | |||
val absolute: Boolean = js.native | |||
} | |||
|
|||
trait DeviceOrientationEventInit extends js.Object { | |||
trait DeviceOrientationEventInit extends dom.raw.EventInit { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend import
ing dom.raw.EventInit
at the top of the file, and then use EventInit
everywhere. There might be other files where this comment applies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 882c079
src/main/scala/org/scalajs/dom/experimental/serviceworkers/ServiceWorkers.scala
Show resolved
Hide resolved
var isReload: js.UndefOr[Boolean] = js.undefined | ||
var request: js.UndefOr[Request] = js.undefined | ||
var clientId: js.UndefOr[String] = js.undefined | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And there should be no blank line here.
src/main/scala/org/scalajs/dom/experimental/serviceworkers/ServiceWorkers.scala
Show resolved
Hide resolved
|
||
/** | ||
* Returns the event's data. It can be any data type. | ||
*/ | ||
val data: Any = js.native | ||
val data: js.Any = js.native |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this become a js.Any
? Is the data
interpreted by JS code in any way? If it is just carried around, it should stay Any
.
@@ -3538,12 +3579,13 @@ class MessageEvent extends Event { | |||
* | |||
* MDN | |||
*/ | |||
def data: Any = js.native | |||
def data: String | Blob | ArrayBuffer = js.native |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MDN says that data
can be any data type, so this should stay Any
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4457811
|
||
@deprecated("Non-standard", "forever") | ||
def initMessageEvent(typeArg: String, canBubbleArg: Boolean, | ||
cancelableArg: Boolean, dataArg: js.Any, originArg: String, | ||
lastEventIdArg: String, sourceArg: Window): Unit = js.native | ||
cancelableArg: Boolean, dataArg: String | Blob | ArrayBuffer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be Any
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4457811
@@ -5648,14 +5718,19 @@ class StyleSheetList extends js.Object { | |||
def update(index: Int, v: StyleSheet): Unit = js.native | |||
} | |||
|
|||
trait CustomEventInit extends EventInit { | |||
var detailArg: js.UndefOr[js.Any] = js.undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure this should an Any
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4457811
@@ -5851,10 +5927,17 @@ class TimeRanges extends js.Object { | |||
|
|||
@js.native | |||
@JSGlobal | |||
class BeforeUnloadEvent extends Event { | |||
class BeforeUnloadEvent extends Event("") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more customary to use js.native
as the arguments to another argument, in order to be confused that ""
is not actually taken into account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I did not know the custom / tips.
That sounds reasonable.
Fixed in b7194a5
@@ -4829,8 +4829,7 @@ trait MutationEventInit extends EventInit { | |||
"WHATWG DOM") | |||
@js.native | |||
@JSGlobal | |||
class MutationEvent(typeArg: String, init: js.UndefOr[MutationEventInit]) | |||
extends Event(typeArg, init) { | |||
class MutationEvent extends Event("", js.undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it has no constructor, its constructor should be marked private
. Otherwise there is nothing preventing to do new MutationEvent
from the Scala side (with a run-time error).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 879d4ae
Used private[this]
instead of private()
, thanks to deprecation warning declaring private constructors in native JS classes is deprecated, because they do not behave the same way as in Scala.js-defined JS classes. Use `private[this]` instead. This will become an error in 1.0.0.
@@ -4772,10 +4822,15 @@ abstract class DocumentType extends Node { | |||
def publicId: String = js.native | |||
} | |||
|
|||
@deprecated("Obsolete.", "WHATWG DOM") | |||
trait MutationEventInit extends EventInit { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this definition? Couldn't we just not define it at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in 96938be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Closes #219
***EventInit
new ***Event()
raises RuntimeError due to lack of required argument@deprecated
based on MDN