Skip to content
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

Does the currentEvent variable make a sense in Inner Invoke? #1191

Closed
dSalieri opened this issue Apr 25, 2023 · 4 comments
Closed

Does the currentEvent variable make a sense in Inner Invoke? #1191

dSalieri opened this issue Apr 25, 2023 · 4 comments

Comments

@dSalieri
Copy link

Now we have this:

  1. Let currentEvent be undefined.
  2. If global is a Window object, then:
    1. Set currentEvent to global’s current event.
    2. If invocationTargetInShadowTree is false, then set global’s current event to event.
  1. If global is a Window object, then set global’s current event to currentEvent.

Can we short into this:

  1. If global is a Window object, then:
    1. If invocationTargetInShadowTree is false, then set global’s current event to event.
  1. If global is a Window object, then set global’s current event to undefined.

I wondered because currentEvent always has undefined value. Do we have a case when this reduction could break the logic?

@annevk
Copy link
Member

annevk commented Apr 25, 2023

I think you are correct that we could simplify this. Because global's current event is always initially undefined and nothing but these steps manipulate it.

This was introduced in #407. @miketaylr do you happen to recall the thinking here?

@annevk
Copy link
Member

annevk commented Apr 25, 2023

Oh wait. Never mind. I think this makes sense when the listener dispatches another event. In that case there will be a current event.

@dSalieri
Copy link
Author

dSalieri commented Apr 26, 2023

@annevk nested events right? In that case it make sense, you're right.

document.body.addEventListener("click", (e) => {
   e.currentTarget.dispatchEvent(new CustomEvent("hello"))
})

@annevk annevk closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2023
@miketaylr
Copy link
Member

I think this makes sense when the listener dispatches another event. In that case there will be a current event.

Yep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants