Skip to content

Commit

Permalink
use isAlpha(…)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Nov 18, 2024
1 parent 2770263 commit d177f4c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/tailwindcss/src/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { Theme } from './theme'
import { compareBreakpoints } from './utils/compare-breakpoints'
import { DefaultMap } from './utils/default-map'
import { isPositiveInteger } from './utils/infer-data-type'
import { isAlpha } from './utils/is-alpha'
import { segment } from './utils/segment'

type VariantFn<T extends Variant['kind']> = (
Expand Down Expand Up @@ -714,9 +715,9 @@ export function createVariants(theme: Theme): Variants {
variants.functional('in', (ruleNode, variant) => {
if (!variant.value || variant.modifier) return null

// Named values should be alphanumeric. This prevents `in-foo-bar` from
// being used as a variant.
if (variant.value.kind === 'named' && !/^[a-zA-Z]+$/i.test(variant.value.value)) {
// Named values should be alpha (tag selector). This prevents `in-foo-bar`
// from being used as a variant.
if (variant.value.kind === 'named' && !isAlpha(variant.value.value)) {
return null
}

Expand Down

0 comments on commit d177f4c

Please sign in to comment.