Fix Processor instance in postcssed object

This commit is contained in:
Andrey Sitnik
2015-07-04 13:42:39 +03:00
parent fda9ee7396
commit f77611df82
2 changed files with 12 additions and 2 deletions
+4 -2
View File
@@ -19,8 +19,10 @@ export default class Processor {
for ( let i of plugins ) {
let type = typeof i;
if ( (type === 'object' || type === 'function') && i.postcss ) {
normalized.push(i.postcss);
} else if ( type === 'object' && Array.isArray(i.plugins) ) {
i = i.postcss;
}
if ( typeof i === 'object' && Array.isArray(i.plugins) ) {
normalized = normalized.concat(i.plugins);
} else {
normalized.push(i);
+8
View File
@@ -44,6 +44,14 @@ describe('Processor', () => {
expect(processor.plugins).to.eql([a]);
});
it('adds new processors from object', () => {
let a = () => 1;
let processor = new Processor();
let other = new Processor([a]);
processor.use({ postcss: other });
expect(processor.plugins).to.eql([a]);
});
it('returns itself', () => {
let a = () => 1;
let b = () => 2;