File tree 2 files changed +8
-3
lines changed
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -93,9 +93,8 @@ angular.module('sgApp', [
93
93
} )
94
94
. filter ( 'addWrapper' , [ 'Styleguide' , function ( Styleguide ) {
95
95
return function ( html ) {
96
- var cls = Styleguide . config . data . commonClass ;
97
- if ( cls ) {
98
- return '<sg-custom-wrapper class="' + cls + '">' + html + '</sg-custom-wrapper>' ;
96
+ if ( Styleguide . config && Styleguide . config . data && Styleguide . config . data . commonClass ) {
97
+ return '<sg-custom-wrapper class="' + Styleguide . config . data . commonClass + '">' + html + '</sg-custom-wrapper>' ;
99
98
}
100
99
return html ;
101
100
} ;
Original file line number Diff line number Diff line change @@ -106,6 +106,12 @@ describe('sgApp module', function() {
106
106
expect ( addWrapper ( input ) ) . to . eql ( input ) ;
107
107
} ) ;
108
108
109
+ it ( 'returns input as-is if Styleguide config is not yet loaded' , function ( ) {
110
+ Styleguide = { } ;
111
+ var input = 'unchanged' ;
112
+ expect ( addWrapper ( input ) ) . to . eql ( input ) ;
113
+ } ) ;
114
+
109
115
it ( 'returns input wrapped inside a <sg-custom-wrapper> tag with common class if Styleguide config has commonClass' , function ( ) {
110
116
Styleguide . config . data . commonClass = 'my-common-class' ;
111
117
var input = 'wrapped' ,
You can’t perform that action at this time.
0 commit comments