diff --git a/packages/fela-plugin-extend/src/__tests__/extend-test.js b/packages/fela-plugin-extend/src/__tests__/extend-test.js index c1f8b556d..5c834bb76 100644 --- a/packages/fela-plugin-extend/src/__tests__/extend-test.js +++ b/packages/fela-plugin-extend/src/__tests__/extend-test.js @@ -156,6 +156,18 @@ describe('Extend plugin', () => { }) }) + it('should filter out null items in extend array', () => { + const base = { + color: 'blue', + extend: [{ backgroundColor: '#ccc' }, null], + } + + expect(extend()(base)).toEqual({ + color: 'blue', + backgroundColor: '#ccc', + }) + }) + it('should not overwrite values with null or undefined', () => { const base = { color: 'blue', diff --git a/packages/fela-plugin-extend/src/index.js b/packages/fela-plugin-extend/src/index.js index 5a4d01ee0..2d4752ebf 100644 --- a/packages/fela-plugin-extend/src/index.js +++ b/packages/fela-plugin-extend/src/index.js @@ -22,7 +22,10 @@ function removeUndefined(style: Object): Object { function extendStyle(style: Object, extension: Object): void { // extend conditional style objects - if (extension.hasOwnProperty('condition')) { + if ( + extension && + Object.prototype.hasOwnProperty.call(extension, 'condition') + ) { if (extension.condition) { // eslint-disable-next-line no-use-before-define assignStyle(style, extend(extension.style))