Skip to content

Commit 714073d

Browse files
authored
Merge pull request #1180 from tailwindcss/pass-config-utils-recursively
Ensure all function properties receive config utils
2 parents c2dcecf + e357624 commit 714073d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

__tests__/resolveConfig.test.js

+25
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@ test('theme values in the extend section are lazily evaluated', () => {
10591059
test('lazily evaluated values have access to the config utils', () => {
10601060
const userConfig = {
10611061
theme: {
1062+
inset: theme => theme('margin'),
10621063
shift: (theme, { negative }) => ({
10631064
...theme('spacing'),
10641065
...negative(theme('spacing')),
@@ -1083,6 +1084,10 @@ test('lazily evaluated values have access to the config utils', () => {
10831084
'3': '3px',
10841085
'4': '4px',
10851086
},
1087+
margin: (theme, { negative }) => ({
1088+
...theme('spacing'),
1089+
...negative(theme('spacing')),
1090+
}),
10861091
},
10871092
variants: {},
10881093
}
@@ -1100,6 +1105,26 @@ test('lazily evaluated values have access to the config utils', () => {
11001105
'3': '3px',
11011106
'4': '4px',
11021107
},
1108+
inset: {
1109+
'-1': '-1px',
1110+
'-2': '-2px',
1111+
'-3': '-3px',
1112+
'-4': '-4px',
1113+
'1': '1px',
1114+
'2': '2px',
1115+
'3': '3px',
1116+
'4': '4px',
1117+
},
1118+
margin: {
1119+
'-1': '-1px',
1120+
'-2': '-2px',
1121+
'-3': '-3px',
1122+
'-4': '-4px',
1123+
'1': '1px',
1124+
'2': '2px',
1125+
'3': '3px',
1126+
'4': '4px',
1127+
},
11031128
shift: {
11041129
'-1': '-1px',
11051130
'-2': '-2px',

src/util/resolveConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function resolveFunctionKeys(object) {
4848

4949
while (val !== undefined && val !== null && index < path.length) {
5050
val = val[path[index++]]
51-
val = isFunction(val) ? val(resolveThemePath) : val
51+
val = isFunction(val) ? val(resolveThemePath, configUtils) : val
5252
}
5353

5454
return val === undefined ? defaultValue : val

0 commit comments

Comments
 (0)