diff --git a/__tests__/applyAtRule.test.js b/__tests__/applyAtRule.test.js index dfb6e281e..631082985 100644 --- a/__tests__/applyAtRule.test.js +++ b/__tests__/applyAtRule.test.js @@ -216,3 +216,29 @@ test('you can apply utility classes without using the given prefix', () => { expect(result.warnings().length).toBe(0) }) }) + +// test('you can apply utility classes without using the given prefix when using a function for the prefix', () => { +// const input = ` +// .foo { @apply .tw-mt-4 .mb-4; } +// ` + +// const expected = ` +// .foo { margin-top: 1rem; margin-bottom: 1rem; } +// ` + +// const config = { +// ...defaultConfig, +// options: { +// ...defaultConfig.options, +// prefix: selector => { +// return 'tw-' +// }, +// }, +// experiments: { shadowLookup: true }, +// } + +// return run(input, config, generateUtilities(config, [])).then(result => { +// expect(result.css).toEqual(expected) +// expect(result.warnings().length).toBe(0) +// }) +// }) diff --git a/src/lib/substituteClassApplyAtRules.js b/src/lib/substituteClassApplyAtRules.js index 5650be024..ecaacff09 100644 --- a/src/lib/substituteClassApplyAtRules.js +++ b/src/lib/substituteClassApplyAtRules.js @@ -1,6 +1,7 @@ import _ from 'lodash' import postcss from 'postcss' import escapeClassName from '../util/escapeClassName' +import prefixSelector from '../util/prefixSelector' function buildClassTable(css) { const classTable = {} @@ -35,7 +36,7 @@ function findClass(classToApply, classTable, shadowLookup, prefix, onError) { if (_.isEmpty(matches)) { if (_.isEmpty(shadowLookup)) { if (prefix) { - classToApply = '.' + prefix + classToApply.substr(1) + classToApply = prefixSelector(prefix, classToApply) matches = _.get(classTable, classToApply, []) if (_.isEmpty(matches)) { if (_.isEmpty(shadowLookup)) {