Skip to content

Commit

Permalink
Merge pull request #18919 from rwjblue/error-on-missing-capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Apr 24, 2020
2 parents f879ca2 + babe75d commit 911f7cc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/@ember/-internals/glimmer/lib/modifiers/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ class InteractiveCustomModifierManager<ModifierInstance>

install(state: CustomModifierState<ModifierInstance>) {
let { element, args, delegate, modifier, tag } = state;

assert(
'Custom modifier managers must define their capabilities using the capabilities() helper function',
typeof delegate.capabilities === 'object' && delegate.capabilities !== null
);

let { capabilities } = delegate;

if (capabilities.disableAutoTracking === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ class CustomModifierManager {
moduleFor(
'Basic Custom Modifier Manager',
class extends ModifierManagerTest {
'@test throws a useful error when missing capabilities'() {
this.registerModifier(
'foo-bar',
setModifierManager(() => {
return {
createModifier() {},
installModifier() {},
updateModifier() {},
destroyModifier() {},
};
}, {})
);

expectAssertion(() => {
this.render('<h1 {{foo-bar}}>hello world</h1>');
}, /Custom modifier managers must define their capabilities/);
}

'@test can register a custom element modifier and render it'(assert) {
let ModifierClass = setModifierManager(
owner => {
Expand Down

0 comments on commit 911f7cc

Please sign in to comment.