Skip to content

Candidate extraction from Clojure/Script files sometimes produce false negatives #17760

Open
@eneroth

Description

@eneroth

What version of Tailwind CSS are you using?

v4.1.4

What build tool (or framework if it abstracts the build tool) are you using?

postcss-cli 11.0.1

What version of Node.js are you using?

v23.11.0

What browser are you using?

Chrome, Safari, Firefox

What operating system are you using?

macOS

Reproduction URL

#17087

Image

Describe your issue

First of all, a huge thank you for including Clojure.

The issue stems from classes written as keywords that contain fractions. For example,

($ :div {:class [:flex :gap-1.5 :p-1]} …)

In this case, the candidates extracted from :gap-1.5 seem to be :gap-1 and 5, which will end up not matching any class present in the compiled HTML: <div class="flex gap-1.5 p-1">…</div>.

A suggested "good enough" solution is to, in addition to considering the keyword when broken down by period (.) separation, additionally consider the whole string as a candidate. I.e. such that it goes from considering the candidates,

["gap-1" "5"]

To

["gap-1" "5" "gap-1.5"]

This may end up producing some valid classes which are not actually present in the code (gap-1 in this case), but is still preferable, as it trades precision for accuracy.

Another, more elaborate solution would be to join candidates pair-wise and accept them iff they produce a valid class. Eg., the candidates ["gap-1" "5" "p-1"] are extracted. When the first pair is joined with ., they produce the candidate gap-1.5, which is therefore accepted in place of the previous two candidates, producing ["gap-1.5" "p-1"]. In the next iteration, the join produces ["gap-1.5.p-1"], which is nonsense, and is therefore rejected.

More discussion can be found towards the end of #17087.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X