If omitting the universal selector in the serialization is possible, we should do it so we obtain a shorter serialization (to match the behavior asserted in cssom/serialize-namespaced-type-selectors.html). For example, if someone writes *|*::before and there is no default namespace, we should serialize to ::before; however, if there is a default namespace, we should serialize to *|*::before. (This is the test case "Universal selector in any namespace followed by pseudo element). This matches the behavior implemented by WebKit; that one case in particular isn't implemented by Gecko, but other cases where the universal selector should be elided are implemented by Gecko but were not previously by Servo. |
||
---|---|---|
.. | ||
attr.rs | ||
bloom.rs | ||
build.rs | ||
builder.rs | ||
Cargo.toml | ||
context.rs | ||
gecko_like_types.rs | ||
lib.rs | ||
matching.rs | ||
parser.rs | ||
README.md | ||
sink.rs | ||
size_of_tests.rs | ||
tree.rs | ||
visitor.rs |
rust-selectors
CSS Selectors library for Rust. Includes parsing and serilization of selectors, as well as matching against a generic tree of elements. Pseudo-elements and most pseudo-classes are generic as well.
Warning: breaking changes are made to this library fairly frequently (13 times in 2016, for example). However you can use this crate without updating it that often, old versions stay available on crates.io and Cargo will only automatically update to versions that are numbered as compatible.
To see how to use this library with your own tree representation,
see Kuchiki’s src/select.rs
.
(Note however that Kuchiki is not always up to date with the latest rust-selectors version,
so that code may need to be tweaked.)
If you don’t already have a tree data structure,
consider using Kuchiki itself.