-
Notifications
You must be signed in to change notification settings - Fork 161
Add overloads of {add,remove}EventListener with options objects #343
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
I do not know what causes the failure here.
|
c861984
to
cac92ee
Compare
584607f
to
083f3cc
Compare
@ramnivas Thanks a lot for the heads up. That would have been confusing if people tried to remove that event listener. |
0c43ad2
to
71eef64
Compare
@busti BTW, you can run |
@ramnivas The problem is that scalafmt does not seem to work correctly for me. Every time I run |
@busti hmm... May be you want to jiggle your code, perhaps by re-formatting comments (they use too many lines, IMO, and could be more readable by merging lines, anyway; see my closed PR for example). Then maybe scalafmt will be awaken! |
@ramnivas I think the comments should be fine. They were too long before, that's why I have created more line-breaks. See: #343 (comment) I have now tried running
I do not know what else to do here. I am using scalafmt in several other projects and it is working as expected. If it doesn't bother you too much I would like to ask again, for you to check the formatting errors on one of your systems and tell me what's wrong. |
For me it has been working just fine. @busti Probably you already did this, but did you try My suggestion above is to give some ill/differently-formatted code and let |
diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala
index 6fe8218..cf591ac 100644
--- a/src/main/scala/org/scalajs/dom/raw/lib.scala
+++ b/src/main/scala/org/scalajs/dom/raw/lib.scala
@@ -2737,8 +2737,8 @@ object EventListenerOptions {
*/
@inline
def apply(capture: js.UndefOr[Boolean] = js.undefined,
- once: js.UndefOr[Boolean] = js.undefined,
- passive: js.UndefOr[Boolean] = js.undefined): EventListenerOptions = {
+ once: js.UndefOr[Boolean] = js.undefined,
+ passive: js.UndefOr[Boolean] = js.undefined): EventListenerOptions = {
val result = js.Dynamic.literal()
capture.foreach(result.capture = _)
@@ -2797,8 +2797,8 @@ class EventTarget extends js.Object {
* MDN
*/
def removeEventListener[T <: Event](`type`: String,
- listener: js.Function1[T, _],
- options: EventListenerOptions): Unit = js.native
+ listener: js.Function1[T, _],
+ options: EventListenerOptions): Unit = js.native
/**
* The EventTarget.addEventListener() method |
71eef64
to
ca5372b
Compare
Thank you @sjrd again for using scalafmt for me. I have failed to mention that I have previously used scala, sbt and scalafmt on all of the above systems. |
…nd removeEventListener Create removeEventListener function which accepts an options object Create companion object to EventListenerOptions with an initializer Formatting fixes for scalafmt Annotate companion instantiator with @inline Indent lines to satisfy scalafmt Remove EventListenerOptions object and apply method
ca5372b
to
1f716f5
Compare
Sorry that this is so late. I had a rather eventful weekend and forgot about it. |
This Pull Request adds an implementation for passing an options object to
addEventListener
.The three options in that object allow for more control about how an event-listener behaves and can be quite useful, especially when working with touchscreen devices.
The documentation was provided by MDN, details about the standard can be read here:
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Parameters
The standard is supported by all major browsers, with the only exception being IE11.
https://caniuse.com/#feat=passive-event-listener