test_candidates_extraction() — tailwindcss Function Reference
Architecture documentation for the test_candidates_extraction() function in mod.rs from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 39f2c8b8_6d09_3c20_0c68_c2ff64acf8f3["test_candidates_extraction()"] c09b3ad8_e61d_4dcb_3819_2280661fbc5d["assert_extract_sorted_candidates()"] 39f2c8b8_6d09_3c20_0c68_c2ff64acf8f3 -->|calls| c09b3ad8_e61d_4dcb_3819_2280661fbc5d style 39f2c8b8_6d09_3c20_0c68_c2ff64acf8f3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
crates/oxide/src/extractor/mod.rs lines 341–458
fn test_candidates_extraction() {
for (input, expected) in [
// Simple utility
("flex", vec!["flex"]),
// Single character utility
("a", vec!["a"]),
// Simple variant with simple utility
("hover:flex", vec!["hover:flex"]),
// Multiple utilities
("flex block", vec!["flex", "block"]),
// Simple utility with dashes
("items-center", vec!["items-center"]),
("items--center", vec!["items--center"]),
// Simple utility with numbers
("px-2.5", vec!["px-2.5"]),
// Arbitrary properties
("[color:red]", vec!["[color:red]"]),
("![color:red]", vec!["![color:red]"]),
("[color:red]!", vec!["[color:red]!"]),
("[color:red]/20", vec!["[color:red]/20"]),
("![color:red]/20", vec!["![color:red]/20"]),
("[color:red]/20!", vec!["[color:red]/20!"]),
// In HTML
(
r#"<div class="flex items-center px-2.5 bg-[#0088cc] text-(--my-color)"></div>"#,
vec![
"class",
"flex",
"items-center",
"px-2.5",
"bg-[#0088cc]",
"text-(--my-color)",
],
),
// In an array, looks like an arbitrary property (because it starts with `[`).
(r#"["flex"]"#, vec!["flex"]),
(r#"["p-2.5"]"#, vec!["p-2.5"]),
(r#"["flex","p-2.5"]"#, vec!["flex", "p-2.5"]),
(r#"["flex", "p-2.5"]"#, vec!["flex", "p-2.5"]),
// Overlapping candidates, outer candidate should win
(
r#"[CssClass("[&:hover]:flex",'italic')]"#,
vec!["[&:hover]:flex", "italic"],
),
(
r#"["flex",["italic",["underline"]]]"#,
vec!["flex", "italic", "underline"],
),
(r#"[:is(italic):is(underline)]"#, vec![]),
(
r#"[:is(italic):is(underline)]:flex"#,
vec!["[:is(italic):is(underline)]:flex"],
),
(r#"[:div {:class ["p-2""#, vec!["p-2"]),
(r#" "text-green"]}"#, vec!["text-green"]),
(r#"[:div.p-2]"#, vec!["p-2"]),
// Longer example with mixed types of variants and utilities
(
"[&>[data-slot=icon]:last-child]:right-2.5",
vec!["[&>[data-slot=icon]:last-child]:right-2.5"],
),
(
"sm:[&>[data-slot=icon]:last-child]:right-2.5",
vec!["sm:[&>[data-slot=icon]:last-child]:right-2.5"],
),
// --------------------------------------------------------
// Exceptions:
//
// Keys inside of a JS object could be a variant-less candidate. Vue example.
("{ underline: true }", vec!["underline", "true"]),
(
r#" <CheckIcon className={clsx('h-4 w-4', { invisible: index !== 0 })} />"#,
vec!["className", "h-4", "w-4", "invisible", "index"],
),
// You can have variants but in a string. Vue example.
(
"{ 'hover:underline': true }",
vec!["hover:underline", "true"],
),
// Important marker on both sides is invalid
("!flex!", vec![]),
// Important marker before a modifier is invalid
("bg-red-500!/20", vec![]),
// HTML start of a tag
("<div", vec![]),
// HTML end of a tag
("</div>", vec![]),
// HTML element on its own
("<div></div>", vec![]),
// Modifier followed by a modifier is invalid
("bg-red-500/20/20", vec![]),
("bg-red-500/20/[20%]", vec![]),
("bg-red-500/20/(--my-opacity)", vec![]),
("bg-red-500/[20%]/20", vec![]),
("bg-red-500/[20%]/[20%]", vec![]),
("bg-red-500/[20%]/(--my-opacity)", vec![]),
("bg-red-500/(--my-opacity)/20", vec![]),
("bg-red-500/(--my-opacity)/[20%]", vec![]),
("bg-red-500/(--my-opacity)/(--my-opacity)", vec![]),
// Arbitrary value followed by an arbitrary value is invalid
("bg-[red]-[blue]", vec![]),
("bg-[red][blue]", vec![]),
// Arbitrary value followed by an arbitrary variable is invalid
("bg-[red]-(--my-color)", vec![]),
("bg-[red](--my-color)", vec![]),
// Important looking utility cannot be followed by another utility
("flex!block", vec![]),
// Invalid variants make the whole candidate invalid
("[foo]/bar:flex", vec![]),
// Utilities cannot start with `_`
("_blank", vec![]),
("hover:_blank", vec![]),
("hover:focus:_blank", vec![]),
] {
assert_extract_sorted_candidates(input, expected);
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does test_candidates_extraction() do?
test_candidates_extraction() is a function in the tailwindcss codebase.
What does test_candidates_extraction() call?
test_candidates_extraction() calls 1 function(s): assert_extract_sorted_candidates.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free