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
query with numerous selectors at once #6
Comments
Thanks for your advice, It is a considerable feature. However, my usage would be a little different from yours. I prefer this way: dom.query_all(&Selector::from("h1, h2, h3")) Because:
This feature may be added in a few days when I am available. BTW, it is also a good timing for me to refactor the selector as I has been always wanting to change the type of the returned value of Edit: Seems it needs me a lot of work to refactor the selector return value. So maybe this feature will be postponed. |
I'm happy to hear this. As for the actual implementation I was hesitating between the two, but I went for what I initially proposed to avoid having to change the To address your first point, I do not see how an " |
dom.query_all(vec![&Selector::from(".question"), &Selector::from(".answer"), ...]);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<style>
h1, h2 {
color: red;
}
</style>
<h1>asd</h1>
<h2>qwe</h2>
</body>
</html> For the selector For the selector in JavaScript, the image below shows how it works: |
I completely forget a To confirm: AND operations would be marked with spaces (such as |
No, the space in `.a .b` means Descendant combinator. You can get more information from this link: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors
Sent from Proton Mail mobile
…-------- Original Message --------
On Oct 20, 2022, 4:40 PM, liabri wrote:
I completely forget a Selector can be more than a tag, you do have a point there. Although the web does use such syntax (and this project is mostly geared towards web use) it still does not sit well with me. I have no experience in JavaScript and find it quite bizarre the syntax used there, for some reason in CSS it makes more sense, maybe because it's a different type of language, however it may just be me x) I suppose it wouldn't be too far-stretching to follow this syntax because of that, though I wouldn't necessarily call it idiomatic rust personally.
To confirm: AND operations would be marked with spaces (such as .a .b) whilst OR operations would be marked with commas (such as h1, h2 or .a, .b) ? If it was completely up to me I would convey AND operations just as they are, but OR operations using the initial syntax I proposed, my reasoning is that .a .b may be considered as a single selector if you think about it, however .a, .b is made up of two separate selectors, which in Rust (to me at least) should be independent structures i.e. Selector.
—
Reply to this email directly, [view it on GitHub](#6 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AFBRNRCM6NAL5YLV4S7GPBDWEEARTANCNFSM6AAAAAARI5AIBU).
You are receiving this because you commented.Message ID: ***@***.***>
|
I'm referring to the creation of a |
`.a.b`, no spaces, and I remember it should have been supported now.
Sent from Proton Mail mobile
…-------- Original Message --------
On Oct 21, 2022, 2:48 AM, liabri wrote:
I'm referring to the creation of a Selector. If OR operations are Selector::from("h1, h2") in your proposition, how would an AND operation be (i.e. selection of the element·s containing all selectors to clarify)? I assumed it'd be Select::from(".a .b"), separation by space.
—
Reply to this email directly, [view it on GitHub](#6 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AFBRNRF3FU7SU3FEICRW66LWEGHZNANCNFSM6AAAAAARI5AIBU).
You are receiving this because you commented.Message ID: ***@***.***>
|
I see, well it all depends if you want to do it from a web perspective or not I suppose. I don't know what would be more preferred by the general user of this library x) If you stick with the web ways, separation by comma definitely seems like the way to go. |
Solved in #7 |
Hello, I would like to
query_all
all the headers (regardless of size) present, as the order matters. If I individually search for each header (h1, h2, h3 etc.) I will get them ordered based on their size, h1 first, h2 second and so on. I've looked through the docs and cannot seem to find a way to do this, so if one is indeed not present I suggest the following syntax.fn query_all(&self, selector: Vec<&Selector>) -> Vec<Element>
so usage would be something like:
dom.query_all(vec![&Selector::from("h1"), &Selector::from("h2"), ...]);
The text was updated successfully, but these errors were encountered: