You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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]
The text was updated successfully, but these errors were encountered: