Skip to content

JIT includes quotes in class names when classes are followed by ' and ] characters #4801

@bakerkretzmar

Description

@bakerkretzmar

What version of Tailwind CSS are you using?

v2.2.4

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

Tailwind CLI

What version of Node.js are you using?

v16.2.0

What browser are you using?

Firefox (v89.0.2)

What operating system are you using?

macOS (11.4)

Reproduction repository

https://github.com/bakerkretzmar/tailwindcss-jit-quotes-repro

Describe your issue

If an arbitrary value in a class name is immediately followed by a single quote mark and another closing bracket, the quote and bracket are included in the generated class name.

For example, this markup:

<h1 class="<?php echo wrap(['class' => 'max-w-[16rem]']); ?>">Hello world</h1>

generates this CSS:

.max-w-\[16rem\]\'\] {
  max-width: 16rem]'
}

The string ['class' => 'max-w-[16rem]'] seems to be the issue, specifically the fact that it ends with ]']. It looks like the JIT engine stops at the second ], interpreting the arbitrary value for the CSS property to be 16rem]'.

Adding a space before those characters (['class' => 'max-w-[16rem] ']) 'fixes' the issue and produces valid CSS.

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