Use nwsapi and dom-selector depending on the selector #3678
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As a new approach, I suggest using
nwsapi
anddom-selector
depending on the selector.Process
nwsapi
can handle, letnwsapi
do the work.dom-selector
takes over.Benchmark
jsdom x 1.20 ops/sec ±7.88% (7 runs sampled)
jsdom x 0.74 ops/sec ±7.79% (6 runs sampled)
jsdom x 0.89 ops/sec ±63.77% (7 runs sampled)
jsdom x 0.75 ops/sec ±6.98% (6 runs sampled)
Note that the performance difference in the sizzle test is due to the selectors that failed has now been resolved and handled correctly.
Caveats
If the selectors are within Selectors level 3, performance should be about the same as before.
However,
nwsapi
has bugs in:not()
,:is()
and:where()
. These are handled bydom-selector
. Therefore, if you are already using these functions, e.g.:not(:is(.foo, .bar))
, you may experience performance degradation.The same applies to
:indeterminate
,:placeholder-shown
and:scope
.