Skip to content

Commit f296055

Browse files
author
Juuso Backman
committed
Merge pull request #320 from hannu/add-wrapper-config
Fix addWrapper issue when styleguide config is not yet loaded
2 parents 1384f61 + 590fd7f commit f296055

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/app/js/app.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ angular.module('sgApp', [
9393
})
9494
.filter('addWrapper', ['Styleguide', function(Styleguide) {
9595
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>';
9998
}
10099
return html;
101100
};

test/angular/app.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ describe('sgApp module', function() {
106106
expect(addWrapper(input)).to.eql(input);
107107
});
108108

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+
109115
it('returns input wrapped inside a <sg-custom-wrapper> tag with common class if Styleguide config has commonClass', function() {
110116
Styleguide.config.data.commonClass = 'my-common-class';
111117
var input = 'wrapped',

0 commit comments

Comments
 (0)