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

Remove prefix as a function #5829

Merged
merged 4 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove prefix as a function related code
  • Loading branch information
RobinMalfait committed Oct 19, 2021
commit 63c799c4bce648f11f1919b80194faf587cb70da
3 changes: 2 additions & 1 deletion src/lib/generateRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ function* resolveMatchedPlugins(classCandidate, context) {
let candidatePrefix = classCandidate
let negative = false

const twConfigPrefix = context.tailwindConfig.prefix || ''
const twConfigPrefix = context.tailwindConfig.prefix

const twConfigPrefixLen = twConfigPrefix.length
if (candidatePrefix[twConfigPrefixLen] === '-') {
negative = true
Expand Down
4 changes: 0 additions & 4 deletions src/lib/setupContextUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
return identifier
}

if (typeof context.tailwindConfig.prefix === 'function') {
return prefixSelector(context.tailwindConfig.prefix, `.${identifier}`).substr(1)
}

return context.tailwindConfig.prefix + identifier
}

Expand Down
5 changes: 1 addition & 4 deletions src/util/prefixSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import parser from 'postcss-selector-parser'
import { tap } from './tap'

export default function (prefix, selector) {
const getPrefix =
typeof prefix === 'function' ? prefix : () => (prefix === undefined ? '' : prefix)

return parser((selectors) => {
selectors.walkClasses((classSelector) => {
tap(classSelector.value, (baseClass) => {
classSelector.value = `${getPrefix('.' + baseClass)}${baseClass}`
classSelector.value = `${prefix}${baseClass}`
})
})
}).processSync(selector)
Expand Down