WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
283222
Poor performance of querySelectorAll() with descendant selectors (:has())
https://bugs.webkit.org/show_bug.cgi?id=283222
Summary
Poor performance of querySelectorAll() with descendant selectors (:has())
Jeff Johnson
Reported
2024-11-15 18:53:56 PST
I discovered this bug while investigating another bug, Poor performance of selector div:has(img) button
https://bugs.webkit.org/show_bug.cgi?id=283220
Steps to reproduce: 1. Open
https://sdpc.a4l.org/search_national.php
2. Open the web inspector 3. document.querySelectorAll('foobar div:has(img) button') Expected results: The node list is returned immediately. Actual results: The node list takes about 3 seconds to return. Since document.querySelectorAll('foobar') contains no items, the rest of the selector should be irrelevant and ignored. But WebKit is still clearly calculating the 'div:has(img) button' part of the selector.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-11-17 17:58:03 PST
<
rdar://problem/140093151
>
Karl Dubost
Comment 2
2024-11-17 18:07:25 PST
var startTime = performance.now(); document.querySelectorAll('foobar div:has(img) button'); var endTime = performance.now(); console.log(`${endTime - startTime} milliseconds`) Safari: 2247 ms Firefox: 2 ms Chrome: 22 ms Safari Technology Preview 207 20621.1.4.3 Firefox Nightly 134.0a1 13424.11.7 Google Chrome Canary 133.0.6843.0 6843.0
Antti Koivisto
Comment 3
2024-11-20 05:52:03 PST
Pull request:
https://github.com/WebKit/WebKit/pull/36893
EWS
Comment 4
2024-11-21 08:19:44 PST
Committed
286908@main
(cdba6f7e0a32): <
https://commits.webkit.org/286908@main
> Reviewed commits have been landed. Closing PR #36893 and removing active labels.
Antti Koivisto
Comment 5
2024-11-21 08:41:55 PST
***
Bug 283220
has been marked as a duplicate of this bug. ***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug