-
Notifications
You must be signed in to change notification settings - Fork 30
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
Skip posting a task for selectionchange
event in some cases
#170
Comments
@rniwa What do you think about this optimization? Chromium is positive about it. It's a web-exposed change. But I guess it won't cause compatibility issues. |
Hi@rniwa Sorry to disturb, any comments on this? Thanks! |
What is the script observable behavior difference? |
On web user side, it has no observable behavior difference because currently we haven't registered any listeners(in the listed script). Skip enqueueing and dispatching this event without listeners might have some benefits on performance, since the browser doesn't need to dispatch events and excute related task and save some CPU cycles. |
If there is no script observable behavior difference, I don't think we need to say one way or another in the spec. |
The callback won't be called if UAs skip to post the task.
The callback will be called only once if UAs skip to post the second task. |
I see. That sounds like something that could potentially pose a web compatibility problem to me. Also, generally speaking, we don't want to change the UA behavior based on whether an event listener is present or not. So that makes me think that we probably don't want to avoid posting a task even when there is no event listener but perhaps we can add a flag to check whether a task to fire |
I see. Maybe the logic here is something like below(flag
|
Well, you need to reset the flag at the beginning of the callback, not at the end, but yeah. |
Got it. Thx for the correction. So officially, we need to write this into the Thanks! |
Yeah, a PR against this repository as well as a PR against web-platform-tests for test coverage. And ideally some indication that multiple implementers are on board. |
Hm... this issue interacts with #53. The spec currently specifies Firefox's behavior of firing |
Hi Rniwa, thanks for the sharing! I've read issue#53 and basically understand what you guys want to do. You'd like to fire I take a look on the definition of Please corret me if my understanding is wrong. Thanks! |
So now we have a PR for spec change and a PR for WPT. |
So my proposal as the editor of a spec is as follows. We introduce boolean state has scheduled selectionchange event on document, input element, and textarea element. We introduce two algorithms:
|
…selection-api#170, a=testonly Automatic update from web-platform-tests Coalesce selectionchange events per w3c/selection-api#170 (#45145) -- wpt-commits: fd3510de36638b07103738b9ff2bfa9ede340797 wpt-pr: 45145
…selection-api#170, a=testonly Automatic update from web-platform-tests Coalesce selectionchange events per w3c/selection-api#170 (#45145) -- wpt-commits: fd3510de36638b07103738b9ff2bfa9ede340797 wpt-pr: 45145
Hello!
We may consider to skip posting a task for the
selectionchange
event in some specific cases like:selectionchange
event if there are no registered listeners;selectionchange
event if the UA already has an queued task for an equivalentselectionchange
event;Here is a simple case when we don't have any registered listener:
Based the below chrome trace, it is noticed that although we don't register any listener, it still posts an async task when we are just changing the text value.
The text was updated successfully, but these errors were encountered: