ensure peer variants don't include multiple ~ characters (#4757)

Fixes: #4726
This commit is contained in:
Robin Malfait 2021-06-23 02:40:52 +02:00 • committed by GitHub
parent b7b2db2592
commit 0413b84c12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 5 deletions

View file

@ -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}`
)
})
)

View file

@ -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)
})