Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-source",
"version": "7.1.0-alpha.1",
"version": "7.2.0-alpha.1",
"description": "A JavaScript framework for creating ambitious web applications",
"keywords": [
"ember-addon"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ moduleFor(
});
}

['@test it throws a useful assertion when dynamic component name is an object'](assert) {
if (!DEBUG) {
assert.expect(0);
return;
}

assert.throws(() => {
this.render('{{component this.componentName}}', {
componentName: { name: 'not-a-component' },
});
}, /The `{{component}}` helper only accepts strings or components/);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that strings are not accepted in strict mode

}

['@test it has an element']() {
let instance;

Expand Down
13 changes: 13 additions & 0 deletions packages/@glimmer/runtime/lib/compiled/opcodes/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import { expect, unwrap } from '@glimmer/debug-util/lib/platform-utils';
import assert from '@glimmer/debug-util/lib/assert';
import { unwrapTemplate } from '@glimmer/debug-util/lib/template';
import { registerDestructor } from '@glimmer/destroyable';
import { hasInternalComponentManager } from '@glimmer/manager/lib/internal/api';
import { managerHasCapability } from '@glimmer/manager/lib/util/capabilities';
import { isConstRef, valueForRef } from '@glimmer/reference/lib/reference';
import { assign } from '@glimmer/util/lib/object-utils';
Expand Down Expand Up @@ -168,6 +169,18 @@ APPEND_OPCODES.add(VM_RESOLVE_DYNAMIC_COMPONENT_OP, (vm, { op1: _isStrict }) =>

vm.loadValue($t1, null); // Clear the temp register

if (DEBUG) {
assert(
component === null ||
component === undefined ||
typeof component === 'string' ||
isCurriedValue(component) ||
((typeof component === 'object' || typeof component === 'function') &&
hasInternalComponentManager(component)),
'The `{{component}}` helper only accepts strings or components'
);
}

let definition: ComponentDefinition | CurriedValue;

if (typeof component === 'string') {
Expand Down
Loading