Home / Function/ cloneCandidate() — tailwindcss Function Reference

cloneCandidate() — tailwindcss Function Reference

Architecture documentation for the cloneCandidate() function in candidate.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310["cloneCandidate()"]
  ba6fca27_7720_5839_0f92_bc2abb8db636["candidate.ts"]
  23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310 -->|defined in| ba6fca27_7720_5839_0f92_bc2abb8db636
  38a143bb_9140_60f2_b4a1_d6d91e416924["baseCandidate()"]
  38a143bb_9140_60f2_b4a1_d6d91e416924 -->|calls| 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310
  7a380dd4_2f8e_5aa7_b4ee_bf219cb7807f["migrateArbitraryVariants()"]
  7a380dd4_2f8e_5aa7_b4ee_bf219cb7807f -->|calls| 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310
  d9972d7e_4ead_d84f_3f97_3cc5f06273b9["migrateAutomaticVarInjection()"]
  d9972d7e_4ead_d84f_3f97_3cc5f06273b9 -->|calls| 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310
  e33960a2_fa25_720d_6e49_e29c569295d2["migrateCamelcaseInNamedValue()"]
  e33960a2_fa25_720d_6e49_e29c569295d2 -->|calls| 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310
  a8ebd8e1_4e38_4a06_28e7_e26261806723["migrateLegacyArbitraryValues()"]
  a8ebd8e1_4e38_4a06_28e7_e26261806723 -->|calls| 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310
  e23cd15e_fdc1_d590_bce2_3d2a9c41fd9f["migrateLegacyClasses()"]
  e23cd15e_fdc1_d590_bce2_3d2a9c41fd9f -->|calls| 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310
  95e8edc9_45de_ca00_e4d2_601d3ae22f9f["migrateModernizeArbitraryValues()"]
  95e8edc9_45de_ca00_e4d2_601d3ae22f9f -->|calls| 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310
  760a1feb_30f8_c4b2_c08b_eab7c29d415e["createCanonicalizeUtilityCache()"]
  760a1feb_30f8_c4b2_c08b_eab7c29d415e -->|calls| 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310
  style 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/candidate.ts lines 220–273

export function cloneCandidate<T extends Candidate>(candidate: T): T {
  switch (candidate.kind) {
    case 'arbitrary':
      return {
        kind: candidate.kind,
        property: candidate.property,
        value: candidate.value,
        modifier: candidate.modifier
          ? { kind: candidate.modifier.kind, value: candidate.modifier.value }
          : null,
        variants: candidate.variants.map(cloneVariant),
        important: candidate.important,
        raw: candidate.raw,
      } satisfies Extract<Candidate, { kind: 'arbitrary' }> as T

    case 'static':
      return {
        kind: candidate.kind,
        root: candidate.root,
        variants: candidate.variants.map(cloneVariant),
        important: candidate.important,
        raw: candidate.raw,
      } satisfies Extract<Candidate, { kind: 'static' }> as T

    case 'functional':
      return {
        kind: candidate.kind,
        root: candidate.root,
        value: candidate.value
          ? candidate.value.kind === 'arbitrary'
            ? {
                kind: candidate.value.kind,
                dataType: candidate.value.dataType,
                value: candidate.value.value,
              }
            : {
                kind: candidate.value.kind,
                value: candidate.value.value,
                fraction: candidate.value.fraction,
              }
          : null,
        modifier: candidate.modifier
          ? { kind: candidate.modifier.kind, value: candidate.modifier.value }
          : null,
        variants: candidate.variants.map(cloneVariant),
        important: candidate.important,
        raw: candidate.raw,
      } satisfies Extract<Candidate, { kind: 'functional' }> as T

    default:
      candidate satisfies never
      throw new Error('Unknown candidate kind')
  }
}

Domain

Subdomains

Frequently Asked Questions

What does cloneCandidate() do?
cloneCandidate() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/candidate.ts.
Where is cloneCandidate() defined?
cloneCandidate() is defined in packages/tailwindcss/src/candidate.ts at line 220.
What calls cloneCandidate()?
cloneCandidate() is called by 8 function(s): baseCandidate, createCanonicalizeUtilityCache, migrateArbitraryVariants, migrateAutomaticVarInjection, migrateCamelcaseInNamedValue, migrateLegacyArbitraryValues, migrateLegacyClasses, migrateModernizeArbitraryValues.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free