File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,6 @@ export default Base.extend({
2121
2222    init ( )  { 
2323        this . options  =  this . _validateOptions ( parser . parse ( this . el ,  this . options ,  true ) ) ; 
24-         if  ( ! this . options . length )  { 
25-             log . error ( "Switch without options cannot be initialized." ) ; 
26-         } 
2724
2825        events . add_event_listener ( this . el ,  "click" ,  "pat-switch--on-click" ,  ( e )  =>  { 
2926            if  ( e . tagName  ===  "A" )  { 
@@ -68,11 +65,24 @@ export default Base.extend({
6865    _validateOptions : function  ( options )  { 
6966        var  correct  =  [ ] ; 
7067
68+         let  logged_error  =  false ; 
7169        for  ( var  i  =  0 ;  i  <  options . length ;  i ++ )  { 
7270            var  option  =  options [ i ] ; 
73-             if  ( option . selector  &&  ( option . remove  ||  option . add ) )  correct . push ( option ) ; 
74-             else  log . error ( "Switch pattern requires selector and one of add or remove." ) ; 
71+             if  ( option . selector  &&  ( option . remove  ||  option . add ) )  { 
72+                 correct . push ( option ) ; 
73+             }  else  { 
74+                 log . error ( 
75+                     "Switch pattern requires selector and one of add or remove." , 
76+                     this . el 
77+                 ) ; 
78+                 logged_error  =  true ; 
79+             } 
7580        } 
81+ 
82+         if  ( ! correct . length  &&  ! logged_error )  { 
83+             log . error ( "Switch without options cannot be initialized." ,  this . el ) ; 
84+         } 
85+ 
7686        return  correct ; 
7787    } , 
7888
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments