Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Preserve explicit transition duration and timing function when overriding transition property ([#14490](https://github.com/tailwindlabs/tailwindcss/pull/14490))
- Change the implementation for `@import` resolution to speed up initial builds ([#14446](https://github.com/tailwindlabs/tailwindcss/pull/14446))
- Remove automatic `var(…)` injection ([#13657](https://github.com/tailwindlabs/tailwindcss/pull/13657))
- Only apply `:hover` states on devices that support `@media (hover: hover)` ([#14500](https://github.com/tailwindlabs/tailwindcss/pull/14500))

## [4.0.0-alpha.24] - 2024-09-11

Expand Down
26 changes: 25 additions & 1 deletion packages/tailwindcss/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,31 @@ export default defineConfig({
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
use: {
...devices['Desktop Firefox'],
// https://playwright.dev/docs/test-use-options#more-browser-and-context-options
launchOptions: {
// https://playwright.dev/docs/api/class-browsertype#browser-type-launch-option-firefox-user-prefs
firefoxUserPrefs: {
// By default, headless Firefox runs as though no pointers
// capabilities are available.
// https://github.com/microsoft/playwright/issues/7769#issuecomment-966098074
//
// This impacts our `hover` variant implementation which uses an
// '(hover: hover)' media query to determine if hover is available.
//
// Available values for pointer capabilities:
// NO_POINTER = 0x00;
// COARSE_POINTER = 0x01;
// FINE_POINTER = 0x02;
// HOVER_CAPABLE_POINTER = 0x04;
//
// Setting to 0x02 | 0x04 says the system supports a mouse
'ui.primaryPointerCapabilities': 0x02 | 0x04,
'ui.allPointerCapabilities': 0x02 | 0x04,
},
},
},
},

/* Test against mobile viewports. */
Expand Down
6 changes: 4 additions & 2 deletions packages/tailwindcss/src/compat/plugin-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1919,8 +1919,10 @@ describe('matchVariant', () => {
"@layer utilities {
@media (width >= 100px) {
@media (width <= 200px) {
.testmin-\\[100px\\]\\:testmax-\\[200px\\]\\:hover\\:underline:hover {
text-decoration-line: underline;
@media (hover: hover) {
.testmin-\\[100px\\]\\:testmax-\\[200px\\]\\:hover\\:underline:hover {
text-decoration-line: underline;
}
}
}
}
Expand Down
136 changes: 89 additions & 47 deletions packages/tailwindcss/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ describe('compiling CSS', () => {
display: flex;
}

.hover\\:underline:hover {
text-decoration-line: underline;
@media (hover: hover) {
.hover\\:underline:hover {
text-decoration-line: underline;
}
}

@media (width >= 768px) {
Expand Down Expand Up @@ -193,8 +195,10 @@ describe('@apply', () => {
text-decoration-line: underline;
}

.foo:hover {
background-color: var(--color-blue-500, #3b82f6);
@media (hover: hover) {
.foo:hover {
background-color: var(--color-blue-500, #3b82f6);
}
}

@media (width >= 768px) {
Expand Down Expand Up @@ -390,16 +394,20 @@ describe('arbitrary variants', () => {
describe('variant stacking', () => {
it('should stack simple variants', async () => {
expect(await run(['focus:hover:flex'])).toMatchInlineSnapshot(`
".focus\\:hover\\:flex:focus:hover {
display: flex;
"@media (hover: hover) {
.focus\\:hover\\:flex:focus:hover {
display: flex;
}
}"
`)
})

it('should stack arbitrary variants and simple variants', async () => {
expect(await run(['[&_p]:hover:flex'])).toMatchInlineSnapshot(`
".\\[\\&_p\\]\\:hover\\:flex p:hover {
display: flex;
"@media (hover: hover) {
.\\[\\&_p\\]\\:hover\\:flex p:hover {
display: flex;
}
}"
`)
})
Expand All @@ -420,13 +428,17 @@ describe('variant stacking', () => {
content: var(--tw-content);
}

.before\\:hover\\:flex:before:hover {
display: flex;
@media (hover: hover) {
.before\\:hover\\:flex:before:hover {
display: flex;
}
}

.hover\\:before\\:flex:hover:before {
content: var(--tw-content);
display: flex;
@media (hover: hover) {
.hover\\:before\\:flex:hover:before {
content: var(--tw-content);
display: flex;
}
}

@supports (-moz-orient: inline) {
Expand Down Expand Up @@ -627,22 +639,24 @@ describe('sorting', () => {
),
),
).toMatchInlineSnapshot(`
".pointer-events-none {
pointer-events: none;
}
".pointer-events-none {
pointer-events: none;
}

.flex {
display: flex;
}
.flex {
display: flex;
}

@media (hover: hover) {
.hover\\:flex:hover {
display: flex;
}
}

.focus\\:pointer-events-none:focus {
pointer-events: none;
}"
`)
.focus\\:pointer-events-none:focus {
pointer-events: none;
}"
`)
})

/**
Expand Down Expand Up @@ -672,16 +686,20 @@ describe('sorting', () => {
display: flex;
}

.hover\\:flex:hover {
display: flex;
@media (hover: hover) {
.hover\\:flex:hover {
display: flex;
}
}

.focus\\:flex:focus {
display: flex;
}

.hover\\:focus\\:flex:hover:focus {
display: flex;
@media (hover: hover) {
.hover\\:focus\\:flex:hover:focus {
display: flex;
}
}

.disabled\\:flex:disabled {
Expand Down Expand Up @@ -715,44 +733,64 @@ describe('sorting', () => {
].sort(() => Math.random() - 0.5),
),
).toMatchInlineSnapshot(`
".group-hover\\:flex:is(:where(.group):hover *) {
display: flex;
"@media (hover: hover) {
.group-hover\\:flex:is(:where(.group):hover *) {
display: flex;
}
}

.group-focus\\:flex:is(:where(.group):focus *) {
display: flex;
}

.peer-hover\\:flex:is(:where(.peer):hover ~ *) {
display: flex;
@media (hover: hover) {
.peer-hover\\:flex:is(:where(.peer):hover ~ *) {
display: flex;
}
}

.group-hover\\:peer-hover\\:flex:is(:where(.group):hover *):is(:where(.peer):hover ~ *) {
display: flex;
@media (hover: hover) {
@media (hover: hover) {
.group-hover\\:peer-hover\\:flex:is(:where(.group):hover *):is(:where(.peer):hover ~ *) {
display: flex;
}
}
}

.peer-hover\\:group-hover\\:flex:is(:where(.peer):hover ~ *):is(:where(.group):hover *) {
display: flex;
@media (hover: hover) {
@media (hover: hover) {
.peer-hover\\:group-hover\\:flex:is(:where(.peer):hover ~ *):is(:where(.group):hover *) {
display: flex;
}
}
}

.group-focus\\:peer-hover\\:flex:is(:where(.group):focus *):is(:where(.peer):hover ~ *) {
display: flex;
@media (hover: hover) {
.group-focus\\:peer-hover\\:flex:is(:where(.group):focus *):is(:where(.peer):hover ~ *) {
display: flex;
}
}

.peer-hover\\:group-focus\\:flex:is(:where(.peer):hover ~ *):is(:where(.group):focus *) {
display: flex;
@media (hover: hover) {
.peer-hover\\:group-focus\\:flex:is(:where(.peer):hover ~ *):is(:where(.group):focus *) {
display: flex;
}
}

.peer-focus\\:flex:is(:where(.peer):focus ~ *) {
display: flex;
}

.group-hover\\:peer-focus\\:flex:is(:where(.group):hover *):is(:where(.peer):focus ~ *) {
display: flex;
@media (hover: hover) {
.group-hover\\:peer-focus\\:flex:is(:where(.group):hover *):is(:where(.peer):focus ~ *) {
display: flex;
}
}

.peer-focus\\:group-hover\\:flex:is(:where(.peer):focus ~ *):is(:where(.group):hover *) {
display: flex;
@media (hover: hover) {
.peer-focus\\:group-hover\\:flex:is(:where(.peer):focus ~ *):is(:where(.group):hover *) {
display: flex;
}
}

.group-focus\\:peer-focus\\:flex:is(:where(.group):focus *):is(:where(.peer):focus ~ *) {
Expand All @@ -763,8 +801,10 @@ describe('sorting', () => {
display: flex;
}

.hover\\:flex:hover {
display: flex;
@media (hover: hover) {
.hover\\:flex:hover {
display: flex;
}
}"
`)
})
Expand Down Expand Up @@ -2104,8 +2144,10 @@ describe('@variant', () => {
expect(optimizeCss(compiled).trim()).toMatchInlineSnapshot(`
"@layer utilities {
@media (any-hover: hover) {
.any-hover\\:hover\\:underline:hover {
text-decoration-line: underline;
@media (hover: hover) {
.any-hover\\:hover\\:underline:hover {
text-decoration-line: underline;
}
}
}
}"
Expand Down
10 changes: 6 additions & 4 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15660,10 +15660,12 @@ describe('custom utilities', () => {
display: flex;
}

.hover\\:foo:hover {
flex-direction: column;
text-decoration-line: underline;
display: flex;
@media (hover: hover) {
.hover\\:foo:hover {
flex-direction: column;
text-decoration-line: underline;
display: flex;
}
}"
`)
})
Expand Down
Loading