Repository: tailwindlabs/tailwindcss
File: packages/tailwindcss/src/candidate.ts (TypeScript)

Code before:
      let dashedIdent: string | null = null
      if (arbitraryValue[0] === '-' && arbitraryValue[1] === '-') {
        dashedIdent = arbitraryValue
        arbitraryValue = `var(${arbitraryValue})`
      } else {
        arbitraryValue = decodeArbitraryValue(arbitraryValue)
      }

      candidate.value = {
        kind: 'arbitrary',
        dataType: typehint || null,
        value: arbitraryValue,
        dashedIdent,
      }
    } else {
      // Some utilities support fractions as values, e.g. `w-1/2`. Since it's
      // ambiguous whether the slash signals a modifier or not, we store the
      // fraction separately in case the utility matcher is interested in it.
      let fraction =
        modifierSegment === null || candidate.modifier?.kind === 'arbitrary'
          ? null
          : value.slice(valueWithoutModifier.lastIndexOf('-') + 1)

      // If the leftover value is an empty string, it means that the value is an
      // invalid named value. This makes the candidate invalid and we can
      // skip continue parsing it.
      if (valueWithoutModifier === '') {
        return null
      }

      candidate.value = {
        kind: 'named',
        value: valueWithoutModifier,
        fraction,
      }
    }
  }

  return candidate
}

function parseModifier(modifier: string): CandidateModifier {
  if (modifier[0] === '[' && modifier[modifier.length - 1] === ']') {
    let arbitraryValue = modifier.slice(1, -1)

    // If an arbitrary value looks like a CSS variable, we automatically wrap
    // it with `var(...)`.
    //
    // But since some CSS properties accept a `<dashed-ident>` as a value
    // directly (e.g. `scroll-timeline-name`), we also store the original
    // value in case the utility matcher is interested in it without

Review comment (suggestion):
```suggestion
      // skip any further parsing.
```

Code after:
      let dashedIdent: string | null = null
      if (arbitraryValue[0] === '-' && arbitraryValue[1] === '-') {
        dashedIdent = arbitraryValue
        arbitraryValue = `var(${arbitraryValue})`
      } else {
        arbitraryValue = decodeArbitraryValue(arbitraryValue)
      }

      candidate.value = {
        kind: 'arbitrary',
        dataType: typehint || null,
        value: arbitraryValue,
        dashedIdent,
      }
    } else {
      // Some utilities support fractions as values, e.g. `w-1/2`. Since it's
      // ambiguous whether the slash signals a modifier or not, we store the
      // fraction separately in case the utility matcher is interested in it.
      let fraction =
        modifierSegment === null || candidate.modifier?.kind === 'arbitrary'
          ? null
          : value.slice(valueWithoutModifier.lastIndexOf('-') + 1)

      // If the leftover value is an empty string, it means that the value is an
      // invalid named value. This makes the candidate invalid and we can
      // skip any further parsing.
      if (valueWithoutModifier === '') {
        return null
      }

      candidate.value = {
        kind: 'named',
        value: valueWithoutModifier,
        fraction,
      }
    }
  }

  return candidate
}

function parseModifier(modifier: string): CandidateModifier {
  if (modifier[0] === '[' && modifier[modifier.length - 1] === ']') {
    let arbitraryValue = modifier.slice(1, -1)

    // If an arbitrary value looks like a CSS variable, we automatically wrap
    // it with `var(...)`.
    //
    // But since some CSS properties accept a `<dashed-ident>` as a value
    // directly (e.g. `scroll-timeline-name`), we also store the original
    // value in case the utility matcher is interested in it without