mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Add substituteHoverableAtRules, previously accidentally ignored
This commit is contained in:
parent
7bd480a40f
commit
4b99d9e5a4
27
src/lib/substituteHoverableAtRules.js
Normal file
27
src/lib/substituteHoverableAtRules.js
Normal file
@ -0,0 +1,27 @@
|
||||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
import cloneNodes from '../util/cloneNodes'
|
||||
|
||||
export default function(options) {
|
||||
return function(css) {
|
||||
css.walkAtRules('hoverable', atRule => {
|
||||
|
||||
atRule.walkRules(rule => {
|
||||
// Might be wise to error if the rule has multiple selectors,
|
||||
// or weird compound selectors like .bg-blue>p>h1
|
||||
rule.selectors = [
|
||||
rule.selector,
|
||||
`.\\@${rule.selector.slice(1)}:hover`,
|
||||
`.\\@${rule.selector.slice(1)}:focus`
|
||||
]
|
||||
})
|
||||
|
||||
const nodes = atRule.nodes
|
||||
const rules = cloneNodes(nodes)
|
||||
|
||||
atRule.parent.insertBefore(atRule, nodes)
|
||||
|
||||
atRule.remove()
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user