mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Make handler optional in object plugins
This commit is contained in:
parent
53dff626a7
commit
94a1d30809
@ -1244,3 +1244,46 @@ test('plugins can be provided as an object with a handler function', () => {
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
test('plugins can provide a config but no handler', () => {
|
||||
const { components, utilities } = processPlugins(
|
||||
[
|
||||
{
|
||||
config: {
|
||||
prefix: 'tw-',
|
||||
},
|
||||
},
|
||||
{
|
||||
handler({ addUtilities }) {
|
||||
addUtilities({
|
||||
'.object-fill': {
|
||||
'object-fit': 'fill',
|
||||
},
|
||||
'.object-contain': {
|
||||
'object-fit': 'contain',
|
||||
},
|
||||
'.object-cover': {
|
||||
'object-fit': 'cover',
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
],
|
||||
makeConfig()
|
||||
)
|
||||
|
||||
expect(components.length).toBe(0)
|
||||
expect(css(utilities)).toMatchCss(`
|
||||
@variants {
|
||||
.object-fill {
|
||||
object-fit: fill
|
||||
}
|
||||
.object-contain {
|
||||
object-fit: contain
|
||||
}
|
||||
.object-cover {
|
||||
object-fit: cover
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
@ -1367,7 +1367,6 @@ test('plugin config modifications are applied', () => {
|
||||
config: {
|
||||
prefix: 'tw-',
|
||||
},
|
||||
handler() {},
|
||||
},
|
||||
],
|
||||
}
|
||||
@ -1416,7 +1415,6 @@ test('user config takes precedence over plugin config modifications', () => {
|
||||
config: {
|
||||
prefix: 'tw-',
|
||||
},
|
||||
handler() {},
|
||||
},
|
||||
],
|
||||
}
|
||||
@ -1468,13 +1466,11 @@ test('plugin config can register plugins that also have config', () => {
|
||||
config: {
|
||||
important: true,
|
||||
},
|
||||
handler() {},
|
||||
},
|
||||
{
|
||||
config: {
|
||||
separator: '__',
|
||||
},
|
||||
handler() {},
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -1530,7 +1526,6 @@ test('plugin configs take precedence over plugin configs registered by that plug
|
||||
config: {
|
||||
prefix: 'inner-',
|
||||
},
|
||||
handler() {},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@ -29,7 +29,7 @@ export default function(plugins, config) {
|
||||
const getConfigValue = (path, defaultValue) => _.get(config, path, defaultValue)
|
||||
|
||||
plugins.forEach(plugin => {
|
||||
const handler = isFunction(plugin) ? plugin : plugin.handler
|
||||
const handler = isFunction(plugin) ? plugin : _.get(plugin, 'handler', () => {})
|
||||
|
||||
handler({
|
||||
postcss,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user