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

Feature Request: ":only-(of || with)-(key || attribute || value)" #16

Open
clintjhill opened this issue Apr 1, 2012 · 0 comments
Open

Comments

@clintjhill
Copy link
Collaborator

I recently had to select a node whose element type appears more than once in a document, but it was the only one using a certain attribute, say “foo”. (Let’s assume the attribute is exclusive to this element type so we can leave out its name.) In other documents using the same stylesheet, however, there are more than one instance of such elements and they should not be selected. Therefore

[foo]

does not work and, actually, using Selectors 3 it doesn’t seem possible to select it directly. What I would have needed is something like the following:

[foo]:only-of-key [foo]:only-with-key

Although I didn’t need it yet, the same could be said about a certain value:

[foo=bar]:only-of-value [foo=bar]:only-with-value

If the combination of key and value had to be the same, which should be enough for most cases including mine:

[foo]:only-of-attribute [foo]:only-with-attribute

Example

– 1
– 2
– 3
– 4

[quz] matches #4
[quz]:only-of-attribute would match #4
[quz]:only-of-key would match #4
[quz]:only-of-value would match #4
[foo] matches #2 and #3
[foo]:only-of-attribute would match #2 and #3
[foo]:only-of-key would match nothing
[foo]:only-of-value would match #2 and #3
[foo=bar] matches #2
[foo=bar]:only-of-attribute would match #2
[foo=bar]:only-of-key would match #2
[foo=bar]:only-of-value would match #2
[=bar] would match #2 and #4
[
=bar]:only-of-attribute would match #2 and #4
[=bar]:only-of-key would match #4
[
=bar]:only-of-value would match nothing
[] /* = [] = [=*] */ would match #2, #3 and #4
[]:only-of-attribute would match #2, #3 and #4
[]:only-of-key would match #4
[]:only-of-value would match #3
:only-of-attribute would match nothing
:only-of-key would match nothing
:only-of-value would match nothing

I’m not sure how this would work with multiple attributes, though.

Once complete please deliver to Christoph Päper [email protected]

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

1 participant