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

Add failing test ensuring that splattributes can be forwarded. #17146

Closed
wants to merge 1 commit into from
Closed
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 @@ -821,6 +821,71 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {
});
}

'@test can forward ...attributes to dynamic component invocation ("splattributes")'() {
this.registerComponent('x-outer', {
ComponentClass: Component.extend({ tagName: '' }),
template: '<XInner ...attributes>{{yield}}</XInner>',
});

this.registerComponent('x-inner', {
ComponentClass: Component.extend({ tagName: '' }),
template: '<div ...attributes>{{yield}}</div>',
});

this.render(strip`
{{#let (component 'x-outer') as |Thing|}}
<Thing data-foo>Hello!</Thing>
{{/let}}
`);

this.assertElement(this.firstChild, {
tagName: 'div',
attrs: { 'data-foo': '' },
content: 'Hello!',
});
}

'@test an inner angle invocation can forward ...attributes through dynamic component invocation ("splattributes")'() {
this.registerComponent('x-outer', {
ComponentClass: Component.extend({ tagName: '' }),
template: `{{#let (component 'x-inner') as |Thing|}}<Thing ...attributes>{{yield}}</Thing>{{/let}}`,
});

this.registerComponent('x-inner', {
ComponentClass: Component.extend({ tagName: '' }),
template: '<div ...attributes>{{yield}}</div>',
});

this.render('<XOuter data-foo>Hello!</XOuter>');

this.assertElement(this.firstChild, {
tagName: 'div',
attrs: { 'data-foo': '' },
content: 'Hello!',
});
}

'@test an inner angle invocation can forward ...attributes through static component invocation ("splattributes")'() {
this.registerComponent('x-outer', {
ComponentClass: Component.extend({ tagName: '' }),
template: `<XInner ...attributes>{{yield}}</XInner>`,
});

this.registerComponent('x-inner', {
ComponentClass: Component.extend({ tagName: '' }),
template: '<div ...attributes>{{yield}}</div>',
});

this.render('<XOuter data-foo>Hello!</XOuter>');

this.assertElement(this.firstChild, {
tagName: 'div',
attrs: { 'data-foo': '' },
content: 'Hello!',
});
}


'@test can include `...attributes` in multiple elements in tagless component ("splattributes")'() {
this.registerComponent('foo-bar', {
ComponentClass: Component.extend({ tagName: '' }),
Expand Down