File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
packages/theming/src/utils Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -354,5 +354,13 @@ describe('getColor', () => {
354354 it ( 'throws an error if shade is invalid' , ( ) => {
355355 expect ( ( ) => getColor ( { theme : DEFAULT_THEME , hue : 'blue' , shade : NaN } ) ) . toThrow ( TypeError ) ;
356356 } ) ;
357+
358+ it ( 'throws an error if transparency is invalid' , ( ) => {
359+ const invalid = DEFAULT_THEME . opacity [ 100 ] + 1 ;
360+
361+ expect ( ( ) => getColor ( { theme : DEFAULT_THEME , hue : 'blue' , transparency : invalid } ) ) . toThrow (
362+ Error
363+ ) ;
364+ } ) ;
357365 } ) ;
358366} ) ;
Original file line number Diff line number Diff line change @@ -112,6 +112,10 @@ const toColor = (
112112 if ( retVal && transparency ) {
113113 const alpha = transparency > 1 ? opacity [ transparency ] : transparency ;
114114
115+ if ( alpha === undefined ) {
116+ throw new Error ( 'Error: invalid `transparency` parameter' ) ;
117+ }
118+
115119 retVal = rgba ( retVal , alpha ) ;
116120 }
117121
You can’t perform that action at this time.
0 commit comments