-
-
Notifications
You must be signed in to change notification settings - Fork 460
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
Use xpath query handler #2230
Use xpath query handler #2230
Conversation
eca6400
to
dc8e037
Compare
|
||
if (!_queryHandlers.TryGetValue(name, out var queryHandler)) | ||
foreach (var kv in handlers) |
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.
Use 4 spaces instead of 2 🧹
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.
ohhh just merged! Let's create a follow up PR
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'll create a PR right away
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 have one ready to go :)
@@ -10,6 +10,8 @@ namespace PuppeteerSharp | |||
{ | |||
internal class CustomQueriesManager | |||
{ | |||
private static readonly string[] CustomQuerySeparators = new[] { "=", "/" }; | |||
private readonly Dictionary<string, PuppeteerQueryHandler> _internalQueryHandlers; |
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.
Suggestion:
Besides _defaultHandler
, we don't need to store the internal handlers in separate fields as they are only used in the constructor to initialize _internalQueryHandlers
.
By changing them from fields to private static creator methods, we can move initialization of _internalQueryHandlers
to declaration and remove the then empty public constructor.
private readonly Dictionary<string, PuppeteerQueryHandler> _internalQueryHandlers = new()
{
["aria"] = AriaHandler(),
["pierce"] = PierceHandler(),
["text"] = TextQueryHandler(),
["xpath"] = XpathHandler(),
};
closes #2085