Use the named_partial selector in DocumentElement::hasContent() - #881
Use the named_partial selector in DocumentElement::hasContent()#881Amoifr wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #881 +/- ##
=========================================
Coverage 98.56% 98.56%
Complexity 389 389
=========================================
Files 24 24
Lines 909 909
=========================================
Hits 896 896
Misses 13 13 ☔ View full report in Codecov by Harness. |
| // anything matched by the "named_exact" selector is also matched by "named_partial", | ||
| // so checking "named_partial" directly gives the same result as "named" while | ||
| // saving the extra driver query the exact-then-partial fallback would make |
There was a problem hiding this comment.
Please remove this comment because it's more about historical context (why we changed this) instead of explaining what happens.
As for the "what happens" part, the code itself is self-explanatory: we're looking for a content on a page, and of course we want to sub-match.
Historically the named selector was always about sub-matching, and the exact match was introduced later on.
2ce9af8 to
8c9316d
Compare
|
Done, comment removed. You're right that the code says it all on its own, the history lesson belongs in the PR, not the file. Thanks for the review @aik099! |
|
Looks good to me. @stof , could be merged? |
Extracted from #880, where @aik099 suggested it as a standalone change (point 3).
hasContent()only needs a boolean answer. With thenamedselector,ElementFinderfirst triesnamed_exactand falls back tonamed_partial, so a miss on the exact match costs an extra driver query. Anything matched bynamed_exactis also matched bynamed_partial, so queryingnamed_partialdirectly returns the same result with a single driver query.Related to #880.