File tree Expand file tree Collapse file tree 4 files changed +36
-6
lines changed Expand file tree Collapse file tree 4 files changed +36
-6
lines changed Original file line number Diff line number Diff line change 4242    "jest" : " ^27.0.6"  ,
4343    "poi" : " 12.10.3"  ,
4444    "prettier" : " ^2.5.0"  ,
45+     "regenerator-runtime" : " ^0.13.9"  ,
4546    "rollup-plugin-typescript2" : " ^0.31.1"  ,
4647    "typescript" : " ^4.3.4"  ,
4748    "vue" : " ^3.0.5"  ,
Original file line number Diff line number Diff line change 1+ import  'regenerator-runtime/runtime' 
12import  {  mount  }  from  '@vue/test-utils' 
3+ 
24import  ContentLoader  from  './ContentLoader' 
35
46describe ( 'ContentLoader' ,  ( )  =>  { 
@@ -200,4 +202,20 @@ describe('ContentLoader', () => {
200202    expect ( wrapper . find ( 'svg' ) . classes ( ) ) . toEqual ( [ 'loader' ] ) 
201203    expect ( wrapper . find ( 'svg' ) . attributes ( ) ) . toMatchObject ( {  id : 'loader'  } ) 
202204  } ) 
205+ 
206+   it ( 'updates the computedViewBox when props change' ,  async  ( )  =>  { 
207+     const  wrapper  =  mount ( ContentLoader ,  { 
208+       props : { 
209+         viewBox : '0 0 100 100' , 
210+       } , 
211+     } ) 
212+ 
213+     expect ( wrapper . find ( 'svg' ) . attributes ( 'viewBox' ) ) . toBe ( '0 0 100 100' ) 
214+ 
215+     await  wrapper . setProps ( {  viewBox : '0 0 200 200'  } ) 
216+     expect ( wrapper . find ( 'svg' ) . attributes ( 'viewBox' ) ) . toBe ( '0 0 200 200' ) 
217+ 
218+     await  wrapper . setProps ( {  viewBox : null ,  width : 50 ,  height : 100  } ) 
219+     expect ( wrapper . find ( 'svg' ) . attributes ( 'viewBox' ) ) . toBe ( '0 0 50 100' ) 
220+   } ) 
203221} ) 
Original file line number Diff line number Diff line change 1- import  {  defineComponent  }  from  'vue' 
1+ import  {  defineComponent ,   computed  }  from  'vue' 
22import  uid  from  './uid' 
33
44export  default  defineComponent ( { 
@@ -52,11 +52,17 @@ export default defineComponent({
5252  } , 
5353
5454  setup ( props )  { 
55-     const  idClip  =  props . uniqueKey  ? `${ props . uniqueKey }  -idClip`  : uid ( ) 
56-     const  idGradient  =  props . uniqueKey  ? `${ props . uniqueKey }  -idGradient`  : uid ( ) 
57-     const  width  =  props . width  ??  400 
58-     const  height  =  props . height  ??  130 
59-     const  computedViewBox  =  props . viewBox  ??  `0 0 ${ width }   ${ height }  ` 
55+     const  idClip  =  computed ( ( )  => 
56+       props . uniqueKey  ? `${ props . uniqueKey }  -idClip`  : uid ( ) 
57+     ) 
58+     const  idGradient  =  computed ( ( )  => 
59+       props . uniqueKey  ? `${ props . uniqueKey }  -idGradient`  : uid ( ) 
60+     ) 
61+     const  width  =  computed ( ( )  =>  props . width  ??  400 ) 
62+     const  height  =  computed ( ( )  =>  props . height  ??  130 ) 
63+     const  computedViewBox  =  computed ( 
64+       ( )  =>  props . viewBox  ??  `0 0 ${ width . value }   ${ height . value }  ` 
65+     ) 
6066
6167    return  { 
6268      idClip, 
Original file line number Diff line number Diff line change @@ -8134,6 +8134,11 @@ regenerator-runtime@^0.13.4:
81348134  resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" 
81358135  integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== 
81368136
8137+ regenerator-runtime@^0.13.9 :
8138+   version "0.13.9" 
8139+   resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" 
8140+   integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== 
8141+ 
81378142regenerator-transform@^0.14.2 :
81388143  version "0.14.5" 
81398144  resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.5.tgz#c98da154683671c9c4dcb16ece736517e1b7feb4" 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments