Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release] Avoid assertion when bound id provided to tagless component #14382

Merged
merged 1 commit into from
Sep 29, 2016
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ moduleFor('Components test: fragment components', class extends RenderingTest {
this.assertText('baz');
}

['@test does not throw an error if `tagName` is an empty string and `id` is bound property specified via template']() {
let template = `{{id}}`;
let FooBarComponent = Component.extend({
tagName: ''
});

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

this.render(`{{#foo-bar id=fooBarId}}{{/foo-bar}}`, { fooBarId: 'baz' });

this.assertText('baz');
Copy link
Member

Choose a reason for hiding this comment

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

Can you test updating the id and resetting it back to the original value? (The point of this test is to make sure we don't throw when you update the id value on a tag less component). 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Should the other tests in this file be doing the same thing?

}

['@test throws an error if when $() is accessed on component where `tagName` is an empty string']() {
let template = `hit dem folks`;
let FooBarComponent = Component.extend({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function buildComponentTemplate({ component, tagName, layout, out

assert('You cannot use `elementId` on a tag-less component: ' + component.toString(), (() => {
let { elementId } = component;
return tagName !== '' || attrs.id === elementId || (!elementId && elementId !== '');
return tagName !== '' || getValue(attrs.id) === elementId || (!elementId && elementId !== '');
})());

assert('You cannot use `attributeBindings` on a tag-less component: ' + component.toString(), (() => {
Expand Down