Skip to content

Commit

Permalink
ensure peer variants don't include multiple ~ characters (#4757)
Browse files Browse the repository at this point in the history
Fixes: #4726
  • Loading branch information
RobinMalfait committed Jun 23, 2021
1 parent b7b2db2 commit 0413b84
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
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)
})

0 comments on commit 0413b84

Please sign in to comment.