Skip to content

Commit

Permalink
Merge pull request #14750 from intercom/gj/assert-tagName-cp
Browse files Browse the repository at this point in the history
assert that a component `tagName` can not be a computed property
  • Loading branch information
rwjblue authored Dec 23, 2016
2 parents 746fb91 + 0ac2bec commit f4d573e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ember-glimmer/lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ const Component = CoreView.extend(
}
}
)());

assert(`You cannot use a computed property for the component's \`tagName\` (${this}).`, !(this.tagName && this.tagName.isDescriptor));
},

rerender() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,20 @@ moduleFor('Components test: curly components', class extends RenderingTest {
this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' });
}

['@test tagName can not be a computed property'](assert) {
let FooBarComponent = Component.extend({
tagName: computed(function() {
return 'foo-bar';
})
});

this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });

expectAssertion(() => {
this.render('{{foo-bar}}');
}, /You cannot use a computed property for the component's `tagName` \(<\(.+>\)\./);
}

['@test class is applied before didInsertElement'](assert) {
let componentClass;
let FooBarComponent = Component.extend({
Expand Down

0 comments on commit f4d573e

Please sign in to comment.