From edc8377f2e8ab836c407bf49e1928361ee23743c Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Sat, 11 Apr 2020 10:53:06 -0400 Subject: [PATCH] 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. --- addon/resolvers/classic/index.js | 1 + tests/unit/resolvers/classic/basic-test.js | 28 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/addon/resolvers/classic/index.js b/addon/resolvers/classic/index.js index e80f605a..7643470b 100644 --- a/addon/resolvers/classic/index.js +++ b/addon/resolvers/classic/index.js @@ -197,6 +197,7 @@ const Resolver = EmberObject.extend({ if ( type === 'component' || type === 'helper' || + type === 'modifier' || (type === 'template' && split[1].indexOf('components/') === 0) ) { return type + ':' + split[1].replace(/_/g, '-'); diff --git a/tests/unit/resolvers/classic/basic-test.js b/tests/unit/resolvers/classic/basic-test.js index c3066974..2428ff7b 100644 --- a/tests/unit/resolvers/classic/basic-test.js +++ b/tests/unit/resolvers/classic/basic-test.js @@ -545,6 +545,34 @@ test('normalization', function(assert) { assert.equal(resolver.normalize('component:fabulous-component'), 'component:fabulous-component'); assert.equal(resolver.normalize('component:fabulousComponent'), 'component:fabulousComponent'); assert.equal(resolver.normalize('template:components/fabulousComponent'), 'template:components/fabulousComponent'); + + // and modifiers + assert.equal(resolver.normalize('modifier:fabulous-component'), 'modifier:fabulous-component'); + + // deprecated when fabulously-missing actually exists, but normalize still returns it + assert.equal(resolver.normalize('modifier:fabulouslyMissing'), 'modifier:fabulouslyMissing'); +}); + +test('camel case modifier is not normalized', function(assert) { + assert.expect(2); + + let expected = { }; + define('appkit/modifiers/other-thing', [], function(){ + assert.ok(false, 'appkit/modifiers/other-thing was accessed'); + + return { default: 'oh no' }; + }); + + define('appkit/modifiers/otherThing', [], function(){ + assert.ok(true, 'appkit/modifiers/otherThing was accessed'); + + return { default: expected }; + }); + + + let modifier = resolver.resolve('modifier:otherThing'); + + assert.strictEqual(modifier, expected); }); test('normalization is idempotent', function(assert) {