mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
cache className resolve
This commit is contained in:
parent
fe70c89718
commit
33ee64665d
@ -1,11 +1,17 @@
|
||||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
import selectorParser from 'postcss-selector-parser'
|
||||
import { useMemo } from './useMemo'
|
||||
|
||||
const classNameParser = selectorParser(selectors => {
|
||||
return selectors.first.filter(({ type }) => type === 'class').pop().value
|
||||
})
|
||||
|
||||
const getClassNameFromSelector = useMemo(
|
||||
selector => classNameParser.transformSync(selector),
|
||||
selector => selector
|
||||
)
|
||||
|
||||
export default function generateVariantFunction(generator) {
|
||||
return (container, config) => {
|
||||
const cloned = postcss.root({ nodes: container.clone().nodes })
|
||||
@ -24,7 +30,7 @@ export default function generateVariantFunction(generator) {
|
||||
rule.selectors = rule.selectors.map(selector => {
|
||||
return modifierFunction({
|
||||
get className() {
|
||||
return classNameParser.transformSync(selector)
|
||||
return getClassNameFromSelector(selector)
|
||||
},
|
||||
selector,
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user