Skip to content

Commit d863de7

Browse files
authored
Prevent content-none from being overridden when conditionally styling ::before/::after (tailwindlabs#13187)
* Prevent content-none from being overridden when conditionally styling before/after * Update changelog * Fix changelog entry --------- Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
1 parent 8309b47 commit d863de7

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Ensure `scale-*` utilities support percentage values ([#13182](https://github.com/tailwindlabs/tailwindcss/pull/13182))
13+
- Prevent `content-none` from being overridden when conditionally styling `::before`/`::after` ([#13187](https://github.com/tailwindlabs/tailwindcss/pull/13187))
1314

1415
### Changed
1516

packages/tailwindcss/src/utilities.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -3430,7 +3430,10 @@ export function createUtilities(theme: Theme) {
34303430
handle: (value) => [decl('will-change', value)],
34313431
})
34323432

3433-
staticUtility('content-none', [['content', 'none']])
3433+
staticUtility('content-none', [
3434+
['--tw-content', 'none'],
3435+
['content', 'none'],
3436+
])
34343437
functionalUtility('content', {
34353438
themeKeys: [],
34363439
handle: (value) => [

packages/tailwindcss/tests/ui.spec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,20 @@ test('scale can be a number or percentage', async ({ page }) => {
233233
expect(await getPropertyValue('#x', 'scale')).toEqual('1.5')
234234
})
235235

236+
// https://github.com/tailwindlabs/tailwindcss/issues/13185
237+
test('content-none persists when conditionally styling a pseudo-element', async ({ page }) => {
238+
let { getPropertyValue } = await render(
239+
page,
240+
html`<div id="x" class="after:content-none after:hover:underline">Hello world</div>`,
241+
)
242+
243+
expect(await getPropertyValue(['#x', '::after'], 'content')).toEqual('none')
244+
245+
await page.locator('#x').hover()
246+
247+
expect(await getPropertyValue(['#x', '::after'], 'content')).toEqual('none')
248+
})
249+
236250
// ---
237251

238252
const preflight = fs.readFileSync(path.resolve(__dirname, '..', 'preflight.css'), 'utf-8')

0 commit comments

Comments
 (0)