Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/fela-plugin-extend/src/__tests__/extend-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 4 additions & 1 deletion packages/fela-plugin-extend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Comment thread
TxHawks marked this conversation as resolved.
) {
if (extension.condition) {
// eslint-disable-next-line no-use-before-define
assignStyle(style, extend(extension.style))
Expand Down