objectToAst() — tailwindcss Function Reference
Architecture documentation for the objectToAst() function in plugin-api.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD a073a4cd_758b_23aa_b3d4_216815e4dd3d["objectToAst()"] 9fbfbf7d_7486_16f1_14be_06acdc92b2cb["keyframesToRules()"] 9fbfbf7d_7486_16f1_14be_06acdc92b2cb -->|calls| a073a4cd_758b_23aa_b3d4_216815e4dd3d ad196438_55f7_af7b_1604_1d75c1c27d8e["buildPluginApi()"] ad196438_55f7_af7b_1604_1d75c1c27d8e -->|calls| a073a4cd_758b_23aa_b3d4_216815e4dd3d 23f7e85c_49fd_cf23_507a_d8d770053d92["entries()"] a073a4cd_758b_23aa_b3d4_216815e4dd3d -->|calls| 23f7e85c_49fd_cf23_507a_d8d770053d92 08f33202_11d1_569a_e8df_de23eb987e2f["rule()"] a073a4cd_758b_23aa_b3d4_216815e4dd3d -->|calls| 08f33202_11d1_569a_e8df_de23eb987e2f a9af385a_fd12_f1d8_7cf0_ccb9b281ca18["atRule()"] a073a4cd_758b_23aa_b3d4_216815e4dd3d -->|calls| a9af385a_fd12_f1d8_7cf0_ccb9b281ca18 85b46de2_edfa_9371_e2c6_e60f3f5346a2["decl()"] a073a4cd_758b_23aa_b3d4_216815e4dd3d -->|calls| 85b46de2_edfa_9371_e2c6_e60f3f5346a2 style a073a4cd_758b_23aa_b3d4_216815e4dd3d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/compat/plugin-api.ts lines 546–588
export function objectToAst(rules: CssInJs | CssInJs[]): AstNode[] {
let ast: AstNode[] = []
rules = Array.isArray(rules) ? rules : [rules]
let entries = rules.flatMap((rule) => Object.entries(rule))
for (let [name, value] of entries) {
if (value === null || value === undefined) continue
// @ts-expect-error
// We do not want `false` present in the types but still need to discard these nodes for
// compatibility purposes
if (value === false) continue
if (typeof value !== 'object') {
if (!name.startsWith('--')) {
if (value === '@slot') {
ast.push(rule(name, [atRule('@slot')]))
continue
}
// Convert camelCase to kebab-case:
// https://github.com/postcss/postcss-js/blob/b3db658b932b42f6ac14ca0b1d50f50c4569805b/parser.js#L30-L35
name = name.replace(/([A-Z])/g, '-$1').toLowerCase()
}
ast.push(decl(name, String(value)))
} else if (Array.isArray(value)) {
for (let item of value) {
if (typeof item === 'string') {
ast.push(decl(name, item))
} else {
ast.push(rule(name, objectToAst(item)))
}
}
} else {
ast.push(rule(name, objectToAst(value)))
}
}
return ast
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does objectToAst() do?
objectToAst() is a function in the tailwindcss codebase.
What does objectToAst() call?
objectToAst() calls 4 function(s): atRule, decl, entries, rule.
What calls objectToAst()?
objectToAst() is called by 2 function(s): buildPluginApi, keyframesToRules.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free