tree-sitter-css/corpus/selectors.txt

205 lines
3.9 KiB
Plaintext

=========================
Universal selectors
=========================
* {}
---
(stylesheet
(rule_set (selectors (universal_selector)) (block)))
=========================
Type selectors
=========================
div, span {}
h1, h2, h3, h4 {}
---
(stylesheet
(rule_set (selectors (tag_name) (tag_name)) (block))
(rule_set (selectors (tag_name) (tag_name) (tag_name) (tag_name)) (block)))
=========================
Class selectors
=========================
.class-a {}
div.class-b, .class-c.class-d {}
---
(stylesheet
(rule_set
(selectors (class_selector (class_name)))
(block))
(rule_set
(selectors
(class_selector (tag_name) (class_name))
(class_selector (class_selector (class_name)) (class_name)))
(block)))
=========================
Id selectors
=========================
#some-id, a#another-id {}
---
(stylesheet
(rule_set
(selectors (id_selector (id_name)) (id_selector (tag_name) (id_name)))
(block)))
=========================
Attribute selectors
=========================
[a] {}
[b=c] {}
[d~=e] {}
a[b] {}
---
(stylesheet
(rule_set (selectors (attribute_selector (attribute_name))) (block))
(rule_set (selectors (attribute_selector (attribute_name) (plain_value))) (block))
(rule_set (selectors (attribute_selector (attribute_name) (plain_value))) (block))
(rule_set (selectors (attribute_selector (tag_name) (attribute_name))) (block)))
=========================
Pseudo-class selectors
=========================
a:hover {}
:nth-child(2) {}
---
(stylesheet
(rule_set
(selectors (pseudo_class_selector (tag_name) (class_name)))
(block))
(rule_set
(selectors (pseudo_class_selector (class_name) (arguments (integer_value))))
(block)))
=========================
Pseudo-element selectors
=========================
a::first-line {}
---
(stylesheet
(rule_set
(selectors (pseudo_element_selector (tag_name) (tag_name)))
(block)))
=========================
Child selectors
=========================
a > b {}
c > d > e {}
---
(stylesheet
(rule_set
(selectors (child_selector (tag_name) (tag_name)))
(block))
(rule_set
(selectors (child_selector
(child_selector (tag_name) (tag_name))
(tag_name)))
(block)))
=========================
Descendant selectors
=========================
a b {}
c d e {}
---
(stylesheet
(rule_set
(selectors (descendant_selector (tag_name) (tag_name)))
(block))
(rule_set
(selectors (descendant_selector
(descendant_selector (tag_name) (tag_name))
(tag_name)))
(block)))
===========================
Nesting selectors
===========================
a {
&.b {}
& c {}
& > d {}
}
---
(stylesheet
(rule_set
(selectors (tag_name))
(block
(rule_set (selectors (class_selector (nesting_selector) (class_name))) (block))
(rule_set (selectors (descendant_selector (nesting_selector) (tag_name))) (block))
(rule_set (selectors (child_selector (nesting_selector) (tag_name))) (block)))))
===========================
Sibling selectors
===========================
a.b ~ c.d {}
.e.f + .g.h {}
---
(stylesheet
(rule_set
(selectors (sibling_selector
(class_selector (tag_name) (class_name))
(class_selector (tag_name) (class_name))))
(block))
(rule_set
(selectors (adjacent_sibling_selector
(class_selector (class_selector (class_name)) (class_name))
(class_selector (class_selector (class_name)) (class_name))))
(block)))
===========================
The :not selector
===========================
a:not(:hover) {}
.b:not(c > .d) {}
---
(stylesheet
(rule_set
(selectors (pseudo_class_selector
(tag_name)
(class_name)
(arguments (pseudo_class_selector (class_name)))))
(block))
(rule_set
(selectors (pseudo_class_selector
(class_selector (class_name))
(class_name)
(arguments (child_selector (tag_name) (class_selector (class_name))))))
(block)))