-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normalize attribute selector for data-*
and aria-*
modifiers
#14037
Conversation
fyi this is technically breaking. Though in practice it may not actually matter. I kinda doubt people are using this feature but today this candidate causes the div to be underlined:
However, after this PR it won't. I think it's probably okay to ship as-is but we'll want to at least make note of this in case we need to follow it up with a fix (and check for |
@thecrypticace Hmm yes indeed. As you say, it's easy to catch this case and check for the valid flags if we want to. Let's for sure make a not though! |
data-
and aria-
modifiersdata-*
and aria-*
modifiers
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
…4040) Fixes #14026 See #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>
Fixes #14026
See #14040 for the v4 fix
When translating
data-
andaria-
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:Since it's fairly common to have attribute selectors with
data-
andaria-
modifiers, this PR will now wrap the attribute in quotes unless these are already wrapped..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']