question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Text and attribute pseudo-selectors

See original GitHub issue

Pre W3C, CSS Selectors only select nodes within XML documents, however they do not select text nodes or attribute values. Frameworks like parsel (scrapy) have successfully implemented pseudo-selectors like ::text or ::attr which allow you to do that.

Given soupsieve’s current architecture, is it possible to add such selectors?

For reference https://parsel.readthedocs.io/en/latest/usage.html#extensions-to-css-selectors

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
facelessusercommented, Oct 25, 2020

While it is certainly possible to implement this. I think I’m going to pass. It adds unnecessary complexity and inefficiency for very little gain. I’m yet to hear how this is more helpful than just calling text on the returned elements.

While I’m open to a conversation on this, as things stand now, there are no plans to implement these.

@gir-bot remove P: maybe @gir-bot add S: wontfix

1reaction
facelessusercommented, Sep 20, 2020

Currently, I have intentionally not implemented any pseudo elements, just pseudo classes. Beautiful soup can access such on the returned element.

Given soupsieve’s current architecture, is it possible to add such selectors?

It is most likely possible, but I would need to decide whether that is a path that I want to go down. If I did go down this path, I would probably support no more than ::text and maybe ::attr.

This would of course add a bit more complexity as pseudo elements can’t be processed in certain cases etc.

I won’t say no, but I’ll leave it as a maybe. If I do this, it may have to wait until I have the time to spend as this would be a fairly big addition.

@gir-bot remove S: triage @gir-bot add T: feature, P: maybe

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pseudo-classes - CSS: Cascading Style Sheets | MDN
Matches an input element that is displaying placeholder text. For example, it will match the placeholder attribute in the <input> and <textarea> ...
Read more >
CSS Pseudo-classes - W3Schools
What are Pseudo-classes? A pseudo-class is used to define a special state of an element. For example, it can be used to: Style...
Read more >
Meet the Pseudo Class Selectors | CSS-Tricks
Text -related pseudo class selectors / elements ... ::first-letter – Selects the first letter of the text in the element. Typical use: drop...
Read more >
CSS Selectors - Attribute, Pseudo & Combinator Selectors
In today's video we are going to explore CSS selectors. We'll start with the basics, going over element, class and ID selectors, ...
Read more >
Complex Selectors - Learn to Code Advanced HTML & CSS
The class selector identifies an element based on its class attribute value, ... padding: 6px 12px; text-decoration: none; } a:hover { color: #ff7b29;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found