-
Notifications
You must be signed in to change notification settings - Fork 1
Selectors
Christopher Wood edited this page Dec 27, 2024
·
2 revisions
Banana currently supports the following minimal list of selectors:
- The universal selector (
*
) - Descendant selectors (a space between two other selectors)
- Tag name selectors
- child selectors (
>
) - id selectors
- class selectors
- Pseudo classes (currently only supporting
:not
,:first-child
,:last-child
,:nth-of-type
, and:nth-child
)
/* universal selector. selects all elements on page */
* {
}
/* descendant. selects all elements that have two divs in their ancestry list */
div div * {
}
/* tag name */
div {
}
/* child selectors. selects all divs that have their parent a div */
div > div {
}
/* id */
#foo {
}
/* class */
.foo {
}
/* pseudo classes */
:not(div) {
}
div:first-child {
}
:not
selects any of the elements that do not match the given selector:
/* selects any element that has a div parent, but is not a div */
div > :not(span) {
}
<div>
<div>not selected</div>
<span> selected </span>
</div>
Selects any element that is the first child of its parent
Selects any element that is the last child of its parent
Selects any element that matches the equation. See mdn documentation for more info
This one has a little bit of weird behavior that differs from the css spec. It filters the input element list without caring about sibling relationships or anything