File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,13 @@ const MILLISECONDS_MULTIPLIER = 1000
1010const TRANSITION_END = 'transitionend'
1111
1212// Shoutout AngusCroll (https://goo.gl/pxwQGp)
13- const toType = obj => ( { } . toString . call ( obj ) . match ( / \s ( [ a - z ] + ) / i) [ 1 ] . toLowerCase ( ) )
13+ const toType = obj => {
14+ if ( obj === null ) {
15+ return `${ obj } `
16+ }
17+
18+ return { } . toString . call ( obj ) . match ( / \s ( [ a - z ] + ) / i) [ 1 ] . toLowerCase ( )
19+ }
1420
1521/**
1622 * --------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -198,8 +198,9 @@ describe('Util', () => {
198198 } )
199199
200200 describe ( 'typeCheckConfig' , ( ) => {
201+ const namePlugin = 'collapse'
202+
201203 it ( 'should check type of the config object' , ( ) => {
202- const namePlugin = 'collapse'
203204 const defaultType = {
204205 toggle : 'boolean' ,
205206 parent : '(string|element)'
@@ -213,6 +214,20 @@ describe('Util', () => {
213214 Util . typeCheckConfig ( namePlugin , config , defaultType )
214215 } ) . toThrow ( new Error ( 'COLLAPSE: Option "parent" provided type "number" but expected type "(string|element)".' ) )
215216 } )
217+
218+ it ( 'should return null to string when null passed' , ( ) => {
219+ const defaultType = {
220+ toggle : 'boolean' ,
221+ parent : '(null|element)'
222+ }
223+ const config = {
224+ toggle : true ,
225+ parent : null
226+ }
227+
228+ Util . typeCheckConfig ( namePlugin , config , defaultType )
229+ expect ( ) . nothing ( )
230+ } )
216231 } )
217232
218233 describe ( 'makeArray' , ( ) => {
You can’t perform that action at this time.
0 commit comments