Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

A simple QuerySelectorAll command #64

Closed
wants to merge 2 commits into from

Conversation

captainbrosset
Copy link

In response to https://bugzilla.mozilla.org/show_bug.cgi?id=770156 and based on https://gist.github.com/3000231 here is a simple queryselectorall command that could be interesting to you.

It doesn't do much for now apart from listing the matched elements and giving the number of elements matched.

Here is a screenshot:
qsa command screenshot

In the gcli version embedded in the Fx devtools, I know there's an inspect command too, but I think it could benefit from listing all matches rather than forcing the user to write a selector that matches only one element.

Anyway, here's the pull request, up to you.

@captainbrosset
Copy link
Author

I totally did not localized strings nor created tests :-)
Doing this now...

@captainbrosset
Copy link
Author

Thanks for the review and feedback.

I've rewritten the command to extract the view creation to a converter.
Also, I've added an onclick handler on each matching node. Using util.findCssSelector(element), clicking on a matching node will run qsa again with the unique selector.

To make things a bit cleaner, I've squashed my commits into 1 and signed it off. I'll therefore close this PR in a minute and open a new one with the squashed commits.

About the usefulness of this command, I admit I started working on it mostly as a way to get into gcli. It's true that given the tools we already have in the dev-tools, it doesn't seem very useful at first. However, with the findCssSelector bit, it may start to be a little bit more interesting to developers, giving them hints on how to write their selectors.
Perhaps a way to continue would be to add things around selector performance and specificity, although I can't thing of anything in particular right now.

Thanks for the feedback again.
Patrick

@captainbrosset
Copy link
Author

I've just opened PR https://github.com/mozilla/gcli/pull/65 with the latest changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants