Skip to content

Commit

Permalink
[BUGFIX beta] Add failing test ensuring that splattributes can be for…
Browse files Browse the repository at this point in the history
…warded.

(cherry picked from commit 4073c1a)
  • Loading branch information
rwjblue committed Jan 22, 2019
1 parent 7eca43f commit 8a99c8a
Showing 1 changed file with 64 additions and 0 deletions.
Expand Up @@ -855,6 +855,70 @@ 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

0 comments on commit 8a99c8a

Please sign in to comment.