No description
Find a file
Philipp Spiess 300524b893
Normalize attribute selectors for data-* and aria-* modifiers (#14040)
Fixes #14026 
See https://github.com/tailwindlabs/tailwindcss/pull/14037 for the v3
fix

When translating `data-` and `aria-` modifiers with attribute selectors,
we currently do not wrap the target attribute in quotes. This only works
for keywords (purely alphabetic words) but breaks as soon as there are
numbers or things like spaces in the attribute:

```html
<div data-id="foo" class="data-[id=foo]:underline">underlined</div>
<div data-id="f1" class="data-[id=1]:underline">not underlined</div>
<div data-id="foo bar" class="data-[id=foo_bar]:underline">not underlined</div>
```

Since it's fairly common to have attribute selectors with `data-` and
`aria-` modifiers, this PR will now wrap the attribute in quotes unless
these are already wrapped.

| Tailwind Modifier  | CSS Selector |
| ------------- | ------------- |
| `.data-[id=foo]`  | `[data-id='foo']`  |
| `.data-[id='foo']`  | `[data-id='foo']`  |
| `.data-[id=foo_i]`  | `[data-id='foo i']`  |
| `.data-[id='foo'_i]`  | `[data-id='foo' i]`  |
| `.data-[id=123]`  | `[data-id='123']`  |

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2024-07-24 16:55:07 +02:00
.github Add support for basic addVariant plugins with new @plugin directive (#13982) 2024-07-11 09:47:26 -04:00
crates Prep next release: 4.0.0-alpha.17 (#13951) 2024-07-04 19:08:10 +02:00
packages Normalize attribute selectors for data-* and aria-* modifiers (#14040) 2024-07-24 16:55:07 +02:00
playgrounds Add support for basic addVariant plugins with new @plugin directive (#13982) 2024-07-11 09:47:26 -04:00
scripts Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
.gitignore Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
.npmrc introduce v4 codebase 2024-03-05 14:29:15 +01:00
.prettierignore Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
Cargo.lock remove Rust benchmarks and fixtures (#13335) 2024-03-23 16:16:40 +01:00
Cargo.toml Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
CHANGELOG.md Normalize attribute selectors for data-* and aria-* modifiers (#14040) 2024-07-24 16:55:07 +02:00
LICENSE Add README, LICENSE, and CONTRIBUTING (#13088) 2024-03-05 14:45:39 -05:00
package.json Bump dependencies (#13738) 2024-05-24 15:07:44 +02:00
pnpm-lock.yaml Add support for basic addVariant plugins with new @plugin directive (#13982) 2024-07-11 09:47:26 -04:00
pnpm-workspace.yaml Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
README.md Copy README file to every package (#13096) 2024-03-06 08:49:31 -05:00
turbo.json introduce v4 codebase 2024-03-05 14:29:15 +01:00
vitest.workspace.ts introduce v4 codebase 2024-03-05 14:29:15 +01:00

Tailwind CSS

A utility-first CSS framework for rapidly building custom user interfaces.

Build Status Total Downloads Latest Release License


Documentation

For full documentation, visit tailwindcss.com.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss Tailwind CSS on GitHub

For chatting with others using the framework:

Join the Tailwind CSS Discord Server

Contributing

If you're interested in contributing to Tailwind CSS, please read our contributing docs before submitting a pull request.