Choosing selectors #960
Replies: 6 comments
-
I think a guideline for choosing selectors is a good idea, although the choice will inherently remain subjective and page contextual. The guideline will only be able to guide, not serve as a reference for correct selectors [on changes]. Nevertheless, it can guide users into choosing good selectors, reducing differences between the declarations, and serve as a diffuse base for review considerations. I imagine a reviewer will often have to conclude to good enough where their preference or the other authors are equally valid given assumptions are made about both the designed or generated website DOM structure and how it may change in the future. Because of the diffuse and assumptuous context/problem space, the guideline should be and probably can only be a broad guidance rather than concrete follow-along/decision-tree guide. Trying to use selectors that will remain valid in the future is a guessing game on what the provider will do. We can only make educated guesses from interpretations of the DOM structure. As a guideline we may be able to formalize and write down these (common) interpretations and guesses. My expectation from most stable to least (if the elements exist) would be something like
Considering specificity the goal of not including unrelated new content and including new content that should be included are in direct conflict. Choosing a good specificity is inherently diffuse and subjective. (Including too much may be more visible, more obvious to spot for having to update the selectors because the content shows up in the versions?) Inspecting CMS for their DOM structure and documenting best practices for those seems unfeasible. There are too many CMS and too few declarations for them each to make this worth it. Given that we are completely exposed and dependent on the upstream services changes to their websites, and the inherent potentially unstable nature of selectors validity, considering and creating a good break and fix workflow would be great if not necessary. Although I feel like even though the exposure is high and wide, websites are likely to remain stable over long times. Companies do not regularly change CMS, core DOM structure, or website designs. To summarize and conclude, I think a reasonable/good guideline would
|
Beta Was this translation helpful? Give feedback.
-
Selectors can indeed be quite complicated to find and here are some thoughts from my experience in adding and maintaining several hundreds of them.
Considering this, here is how I would structure this guidelines document:
|
Beta Was this translation helpful? Give feedback.
-
I'm probably not going to say much better than @martinratinaud and @Kissaki but maybe wording things differently will be helpful in writing this guide. The most important thing is that we need to choose the CSS selectors that are most resistant to document changes because this reduces the cost of maintenance. Stable selectors are like Unstable selectors are like It would be interesting to show examples of DOMs and associated selectors with different levels of difficulty. |
Beta Was this translation helpful? Give feedback.
-
I mainly agree with previous comments. Here are the points I would like to highlight:
For example:
|
Beta Was this translation helpful? Give feedback.
-
Everyone included points that I agree are necessary. I do not have many new recommendations other then a section that documents a workflow for reviewers. However I highlighted all of the main points from everyone's comments in a structure that I find would be beneficial in this guide. 1. Briefly describe the goal of finding the best selectors.
2. Briefly describe how selectors work
3. What is considered a good/stable selector.
4. What is considered a bad/unstable selector
5. Example of DOMs with associated selectors
6. Include a section that describes best workflow for reviewers
To summarize how I’d structure the guidelines document:1. Highlight goals and challenges |
Beta Was this translation helpful? Give feedback.
-
Thank you everyone for your contributions! I know it has been a long time coming, but you can finally preview and review the proposal for the selectors choice guidelines! The reviewer guidelines are live and are, as always, open for improvements 🙂 |
Beta Was this translation helpful? Give feedback.
-
What selectors do you want to write and see in Open Terms Archive declarations?
Goal
This discussion aims at defining common guidelines for what can be considered “good” selectors, in order to minimise ongoing maintenance and limit variation based on individual preferences, so that contributors and reviewers can achieve fast integration of documents with limited effort and no personal criticism.
Context
Selectors are used to target parts of documents that should be stored or removed. There are usually several valid ways to select the same parts of a document, and an important part of the review process of a suggested tracking is to check the validity and relevance of those selectors.
These selectors are the most commonly discussed and modified part during a review (for their choice, order or specificity).
Urgency
There has been a noted increase in contributions from new contributors in the last two weeks, and the time spent on reviews increases accordingly. The cost-to-benefit ratio of writing guidelines vs 1-on-1 training is thus shifting in favour of writing.
Deliverable
The end result of this discussion will be a set of opinions, arguments and hopefully converging suggested guidelines, from which a final set of guidelines will be derived by @OpenTermsArchive/Core and documented either in a wiki page or in a CONTRIBUTING file. The final writeup will be open for review to all contributors before integration.
Decision process
The decision process will be debate and consensus-based, with final arbitration by @OpenTermsArchive/Core as last resort if necessary.
The planned time for discussion is 7 days, which can be extended once in case of noted divergences.
Beta Was this translation helpful? Give feedback.
All reactions