Skip to content

Commit edc8377

Browse files
author
Robert Jackson
committed
Remove automatic dasherization of modifiers.
Modifiers (like helpers and components) should not get automatically dasherized when looked up. Using `{{fooBar}}` and `{{foo-bar}}` interchangably to mean a given modifier is **very** confusing behavior, and was never intended. Unfortunately, when user land modifiers were added to Ember we forgot to update this guard to prevent dasherization.
1 parent 076a93e commit edc8377

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

addon/resolvers/classic/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ const Resolver = EmberObject.extend({
197197
if (
198198
type === 'component' ||
199199
type === 'helper' ||
200+
type === 'modifier' ||
200201
(type === 'template' && split[1].indexOf('components/') === 0)
201202
) {
202203
return type + ':' + split[1].replace(/_/g, '-');

tests/unit/resolvers/classic/basic-test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,34 @@ test('normalization', function(assert) {
545545
assert.equal(resolver.normalize('component:fabulous-component'), 'component:fabulous-component');
546546
assert.equal(resolver.normalize('component:fabulousComponent'), 'component:fabulousComponent');
547547
assert.equal(resolver.normalize('template:components/fabulousComponent'), 'template:components/fabulousComponent');
548+
549+
// and modifiers
550+
assert.equal(resolver.normalize('modifier:fabulous-component'), 'modifier:fabulous-component');
551+
552+
// deprecated when fabulously-missing actually exists, but normalize still returns it
553+
assert.equal(resolver.normalize('modifier:fabulouslyMissing'), 'modifier:fabulouslyMissing');
554+
});
555+
556+
test('camel case modifier is not normalized', function(assert) {
557+
assert.expect(2);
558+
559+
let expected = { };
560+
define('appkit/modifiers/other-thing', [], function(){
561+
assert.ok(false, 'appkit/modifiers/other-thing was accessed');
562+
563+
return { default: 'oh no' };
564+
});
565+
566+
define('appkit/modifiers/otherThing', [], function(){
567+
assert.ok(true, 'appkit/modifiers/otherThing was accessed');
568+
569+
return { default: expected };
570+
});
571+
572+
573+
let modifier = resolver.resolve('modifier:otherThing');
574+
575+
assert.strictEqual(modifier, expected);
548576
});
549577

550578
test('normalization is idempotent', function(assert) {

0 commit comments

Comments
 (0)