Support unquoted lists as default theme function values
This commit is contained in:
parent
72697fd580
commit
525d03b7dc
2 changed files with 23 additions and 2 deletions
|
|
@ -88,3 +88,24 @@ test('quotes are preserved around default values', () => {
|
|||
expect(result.warnings().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
test('an unquoted list is valid as a default value', () => {
|
||||
const input = `
|
||||
.heading { font-family: theme('fonts.sans', Helvetica, Arial, sans-serif); }
|
||||
`
|
||||
|
||||
const output = `
|
||||
.heading { font-family: Helvetica, Arial, sans-serif; }
|
||||
`
|
||||
|
||||
return run(input, {
|
||||
theme: {
|
||||
fonts: {
|
||||
serif: 'Constantia',
|
||||
},
|
||||
},
|
||||
}).then(result => {
|
||||
expect(result.css).toEqual(output)
|
||||
expect(result.warnings().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import functions from 'postcss-functions'
|
|||
export default function(config) {
|
||||
return functions({
|
||||
functions: {
|
||||
theme: (path, defaultValue) => {
|
||||
return _.get(config.theme, _.trim(path, `'"`), defaultValue)
|
||||
theme: (path, ...defaultValue) => {
|
||||
return _.get(config.theme, _.trim(path, `'"`), defaultValue.join(', '))
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue