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 beta] Avoid assertion when id= is provided to tagless components. #14106

Merged
merged 1 commit into from
Aug 21, 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
2 changes: 1 addition & 1 deletion packages/ember-glimmer/lib/syntax/curly-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class CurlyComponentManager {

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

assert('You cannot use `attributeBindings` on a tag-less component: ' + component.toString(), (() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,41 @@ moduleFor('Components test: fragment components', class extends RenderingTest {
}, /You cannot use `elementId` on a tag-less component/);
}

['@test throws an error if `tagName` is an empty string and `elementId` is specified via template']() {
let template = `hit dem folks`;
let FooBarComponent = Component.extend({
tagName: ''
});

this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template });
expectAssertion(() => {
this.render(`{{#foo-bar elementId='turntUp'}}{{/foo-bar}}`);
}, /You cannot use `elementId` on a tag-less component/);
}

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

this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template });
this.render(`{{#foo-bar}}{{/foo-bar}}`);
this.assertText('baz');
}

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

this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template });
this.render(`{{#foo-bar id='baz'}}{{/foo-bar}}`);
this.assertText('baz');
}

['@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 !== '' || (!elementId && elementId !== '');
return tagName !== '' || attrs.id === elementId || (!elementId && elementId !== '');
})());

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