Skip to content
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

feat(selectors): proximity selectors #4923

Merged
merged 1 commit into from Jan 7, 2021
Merged

feat(selectors): proximity selectors #4923

merged 1 commit into from Jan 7, 2021

Conversation

dgozman
Copy link
Contributor

@dgozman dgozman commented Jan 7, 2021

No description provided.

@Aaron-Pool
Copy link

Hey, I know I'm not a contribute or anything, but just wanted to drop my personal experience. For me, the most useful proximity-style selectors are what I refer to as "axis" selectors. I have helper functions that use element handle bounding boxes to locate the element that is closest purely from the perspective of the x or y axis. This allows me to, for example, look up a form label and then get the form input that corresponds to it in a reliable way. I can also combine these two to do a table style lookup that uses different elements for the x and y axis lookup references.

@dgozman
Copy link
Contributor Author

dgozman commented Jan 7, 2021

Hey, I know I'm not a contribute or anything, but just wanted to drop my personal experience. For me, the most useful proximity-style selectors are what I refer to as "axis" selectors. I have helper functions that use element handle bounding boxes to locate the element that is closest purely from the perspective of the x or y axis. This allows me to, for example, look up a form label and then get the form input that corresponds to it in a reliable way. I can also combine these two to do a table style lookup that uses different elements for the x and y axis lookup references.

@Aaron-Pool This totally makes sense. I think we will introduce some kind of "table" selector to help with tables. Not sure about axis yet, perhaps "aligned" or something? I'd need to gather more information about axis-specific use cases that do not work with "right-of" and similar.

@Aaron-Pool
Copy link

Aaron-Pool commented Jan 7, 2021

Consider this example:
image

This is not a site that I control the layout of, I'm just trying to automate a task I need to perform on it/scrape it for data. The elements are not labeled in a semantic way and both the section header and whatever element contains "value" are a simple span element. To keep the task from being prone to breakage, I really just want the selector equivalent of "I want whatever is vertically aligned with this label, to its right".

But if I understand the current API correctly :right-of will get me 3 different elements, and :near will get me both the value and the section header, assuming it gets the label at all. It may only return the section header, depending on the width of the container.

@dgozman
Copy link
Contributor Author

dgozman commented Jan 7, 2021

But if I understand the current API correctly :right-of will get me 3 different elements, and :near will get me both the value and the section header, assuming it gets the label at all. It may only return the section header, depending on the width of the container.

Yep, that matches my understanding. Let me file this as a feature request.

@dgozman dgozman merged commit eb9ea20 into microsoft:master Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants