@@ -352,6 +352,38 @@ describe('CSSStyleDeclaration', () => {
352
352
expect ( style . fillOpacity ) . toEqual ( '0' ) ;
353
353
} ) ;
354
354
355
+ test ( 'setting a value to empty string or null should remove the value' , ( ) => {
356
+ var style = new CSSStyleDeclaration ( ) ;
357
+ style . setProperty ( 'opacity' , 0 ) ;
358
+ expect ( style . opacity ) . toEqual ( '0' ) ;
359
+ style . setProperty ( 'opacity' , null ) ;
360
+ expect ( style . opacity ) . toEqual ( '' ) ;
361
+ style . setProperty ( 'opacity' , 0 ) ;
362
+ expect ( style . opacity ) . toEqual ( '0' ) ;
363
+ style . setProperty ( 'opacity' , '' ) ;
364
+ expect ( style . opacity ) . toEqual ( '' ) ;
365
+ } ) ;
366
+
367
+ test ( 'setting a value to an object implementing toString() should work' , ( ) => {
368
+ var style = new CSSStyleDeclaration ( ) ;
369
+ var object = {
370
+ toString : function ( ) {
371
+ return 1 ;
372
+ } ,
373
+ } ;
374
+ style . setProperty ( 'opacity' , object ) ;
375
+ expect ( style . opacity ) . toEqual ( '1' ) ;
376
+ style . setProperty ( 'opacity' , [ 0 ] ) ;
377
+ expect ( style . opacity ) . toEqual ( '0' ) ;
378
+ object = {
379
+ toString : function ( ) {
380
+ return [ 1 ] ; // Not recursive: [1].toString() === '1'
381
+ } ,
382
+ } ;
383
+ style . setProperty ( 'opacity' , object ) ;
384
+ expect ( style . opacity ) . toEqual ( '0' ) ;
385
+ } ) ;
386
+
355
387
test ( 'onchange callback should be called when the csstext changes' , ( ) => {
356
388
var style = new CSSStyleDeclaration ( function ( cssText ) {
357
389
expect ( cssText ) . toEqual ( 'opacity: 0;' ) ;
0 commit comments