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

Return rules by id #39

Closed
yellowandy opened this issue Jun 28, 2012 · 2 comments
Closed

Return rules by id #39

yellowandy opened this issue Jun 28, 2012 · 2 comments

Comments

@yellowandy
Copy link

Hi, I didn't see any way to return all the rules associated with a particular selector. Looks like I would just have to iterate over all delcaration blocks and then get the selector and return the values if a hit was found. Any plans on adding something similar or am I missing anything? Thanks and great library.

@sabberworm
Copy link
Contributor

No, there is no such thing (assuming I’m understanding you correctly). That’s mostly because selectors are (apart from being split at the comma) not really parsed at all and thus, very fragile. Selectors are also not normalized, so searching for #test > a will not yield any results when your selector is #test>a.
Parsing selectors is high on my would-really-improve-the-quality-of-the-software list (especially as it would help me get rid of a lot of bugs such as the selector a[href~="{"] yielding a parse error since CSSParser doesn’t know that the { is not really the start of a declaration block but instead part of the selector) but unfortunately, it’s not high on the list of priorities because parsing selectors is difficult and I’ve never needed it in any of my projects.
That being said, however, feel free to fork the project, add a utility method to CSSDocument or CSSList that iterates through all declaration blocks and returns the ones where one of the selectors matches a given pattern and I’ll merge your changes.

@sabberworm
Copy link
Contributor

I’m closing this as there has not been a response to my WONTFIX-type answer…

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

No branches or pull requests

2 participants