Skip to content
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

Ensure peer variants don't include multiple ~ characters #4757

Merged
merged 1 commit into from Jun 23, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/jit/corePlugins.js
Expand Up @@ -201,11 +201,8 @@ export default {
return null
}

return applyPseudoToMarker(
variantSelector,
peerMarker,
state,
(marker, selector) => `${marker} ~ ${selector}`
return applyPseudoToMarker(variantSelector, peerMarker, state, (marker, selector) =>
selector.trim().startsWith('~') ? `${marker}${selector}` : `${marker} ~ ${selector}`
)
})
)
Expand Down
26 changes: 26 additions & 0 deletions tests/jit/variants.test.js
Expand Up @@ -32,3 +32,29 @@ test('variants', () => {
expect(result.css).toMatchFormattedCss(expected)
})
})

test('stacked peer variants', async () => {
let config = {
mode: 'jit',
purge: [{ raw: 'peer-disabled:peer-focus:peer-hover:border-blue-500' }],
corePlugins: { preflight: false },
theme: {},
plugins: [],
}

let css = `
@tailwind base;
@tailwind components;
@tailwind utilities;
`

let expected = `
.peer:disabled:focus:hover ~ .peer-disabled\\:peer-focus\\:peer-hover\\:border-blue-500 {
--tw-border-opacity: 1;
border-color: rgba(59, 130, 246, var(--tw-border-opacity));
}
`

let result = await run(css, config)
expect(result.css).toIncludeCss(expected)
})