Combine rulesets from all matching mixins

This commit is contained in:
Adam Wathan 2017-08-25 14:11:57 -04:00
parent 308499dcad
commit f42bb0b2bc

View File

@ -8,20 +8,19 @@ const shadows = require('./generators/shadows')
const flex = require('./generators/flex')
function findMixin(css, mixin, onError) {
let match
const matches = []
css.walkRules((rule) => {
if (_.trimStart(rule.selector, '.') === mixin) {
match = rule
return false
matches.push(rule)
}
})
if (_.isUndefined(match) && _.isFunction(onError)) {
if (_.isEmpty(matches) && _.isFunction(onError)) {
onError()
}
return match.clone().nodes
return _.flatten(matches.map(match => match.clone().nodes))
}
function addCustomMediaQueries(css, { breakpoints }) {