From d39e4749bd1a68799fd0f37e11d641d4c93f8712 Mon Sep 17 00:00:00 2001 From: Kevin Yang Date: Wed, 30 Nov 2016 15:33:52 -0500 Subject: [PATCH] Handle undefined local-class (#57) * handle undefined local-class case * add test --- addon/helpers/local-class.js | 2 +- tests/unit/helpers/local-class-test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addon/helpers/local-class.js b/addon/helpers/local-class.js index db150d4b..cfdd12b8 100644 --- a/addon/helpers/local-class.js +++ b/addon/helpers/local-class.js @@ -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(' '); } diff --git a/tests/unit/helpers/local-class-test.js b/tests/unit/helpers/local-class-test.js index a410bdd5..c7902c2b 100644 --- a/tests/unit/helpers/local-class-test.js +++ b/tests/unit/helpers/local-class-test.js @@ -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) {