-
Notifications
You must be signed in to change notification settings - Fork 294
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
Define a "has listeners for" algorithm on EventTarget #660
base: main
Are you sure you want to change the base?
Conversation
7ae41a1
to
8e5d463
Compare
Is this the result of a failed check, or is there a problem with the build? |
@annevk ready for review(I think). |
@annevk Ping on this one. From your Github timeline it looks like you were away for a couple of weeks, hope you had a nice holiday... |
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.
Thanks, this looks pretty good, but I would phrase it a little differently:
"An EventTarget object target is said to have a listener for type if target's event listener list contains an event listener whose type is type."
I think something along those lines is probably sufficient here. (To figure out what linking text to allow we might want to look at the phrasing for future callers in advance, too.)
Ok thanks, I think an example of callers would be Step 9 of unload a document, which I guess could read like: |
Sorry for the continued delay in replies, it'll hopefully get better soon. I'd expect we'd update that caller to be more specific and no longer reference the previous step. (This might also mean it has to be moved, in case the listeners removing themselves at that step still counts.) |
dom.bs
Outdated
@@ -995,6 +995,9 @@ and a <dfn export for=EventTarget>legacy-canceled-activation behavior</dfn> algo | |||
<p class="note no-backref">These algorithms only exist for checkbox and radio <{input}> elements and | |||
are not to be used for anything else. [[!HTML]] | |||
|
|||
<p> An {{EventTarget}} object <var>target</var> is said to <dfn export>have a listener for</dfn> <var>type</var> if <var>target</var>'s <a>event listener list</a> <a for=list>contains</a> an |
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.
No space after <p>
. Also needs to be rewrapped for 100 columns.
@annevk thanks, comment addressed. Yes you are right about the unload steps, we could reword it and put the link to here in a step before the actual firing of the event. I'd be happy to follow up on that too... |
Thanks! @TimothyGu since you've been looking at events and similar algorithms, would you please double check? |
It should be fine. I don't know the event dispatching process too well, but could it be possible that when "firing an event at the |
Reminds me of a discussion we had previously at #453 (comment), because I assumed one would have to check the entire "event-path"... |
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'm going to approve this, but let's wait with landing it until we have some dependency PRs lined up to make sure it really works.
Actually, we should probably also add a note here to discourage new usage as checking for listeners is bad practice (as we point out in https://dom.spec.whatwg.org/#observing-event-listeners). |
117cd25
to
399b58b
Compare
Ok, I've added a note, let me know what you think. |
Thanks, I tweaked that a bit in a follow-up commit (will squash before landing). Let me know what you think. As per above, I'm going to wait with landing until Service Workers / HTML are closer to adopting this. |
Looks good to me, I previously got a warning when using |
@gterzian As a note there are many alternatives, like "could not" or "would not." "Can not" isn't really a word. |
@TimothyGu thanks! By the way the change is from my use of 'can not'(which was an attempt at avoiding the use of 'should'), to a 'is not', so definitely progress if 'can not' is not a word :) |
The reason I wanted to avoid "can not" is that an API designer certainly can rely on it, but they are not supposed to. |
Fix #453
💥 Error: 500 Internal Server Error 💥
PR Preview failed to build. (Last tried on Jan 15, 2021, 7:33 AM UTC).
More
PR Preview relies on a number of web services to run. There seems to be an issue with the following one:
🚨 CSS Spec Preprocessor - CSS Spec Preprocessor is the web service used to build Bikeshed specs.
🔗 Related URL
If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please file an issue.