Skip to content

Commit

Permalink
Handle undefined local-class (ember-cli#57)
Browse files Browse the repository at this point in the history
* handle undefined local-class case

* add test
  • Loading branch information
Kevin Yang authored and dfreeman committed Nov 30, 2016
1 parent a2cb278 commit d39e474
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/helpers/local-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function localClass(params, hash) {
if (!hash.from) { return ''; }

let styles = resolveSource(hash.from);
let classes = params[0].split(/\s+/);
let classes = (params[0] || '').split(/\s+/);

return classes.map(style => styles[style]).filter(Boolean).join(' ');
}
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/helpers/local-class-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ test('with an empty source specified', function(assert) {
assert.equal(localClass(['abc'], { from: null }), '');
});

test('with an undefined local class', function(assert) {
assert.equal(localClass([undefined], { from: null }), '');
});

export default { foo: '_foo_123', bar: '_bar_789' };

test('with a string source specified', function(assert) {
Expand Down

0 comments on commit d39e474

Please sign in to comment.