From 8a99c8acfe74db711110e23dfd53708fadd767aa Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 23 Oct 2018 14:20:45 -0400 Subject: [PATCH] [BUGFIX beta] Add failing test ensuring that splattributes can be forwarded. (cherry picked from commit 4073c1aaa177555eb918937b1dd1ef9cbd40d673) --- .../angle-bracket-invocation-test.js | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/angle-bracket-invocation-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/angle-bracket-invocation-test.js index 811e58846f0..59ed820f073 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/angle-bracket-invocation-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/angle-bracket-invocation-test.js @@ -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: '{{yield}}', + }); + + this.registerComponent('x-inner', { + ComponentClass: Component.extend({ tagName: '' }), + template: '
{{yield}}
', + }); + + this.render(strip` + {{#let (component 'x-outer') as |Thing|}} + Hello! + {{/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|}}{{yield}}{{/let}}`, + }); + + this.registerComponent('x-inner', { + ComponentClass: Component.extend({ tagName: '' }), + template: '
{{yield}}
', + }); + + this.render('Hello!'); + + 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: `{{yield}}`, + }); + + this.registerComponent('x-inner', { + ComponentClass: Component.extend({ tagName: '' }), + template: '
{{yield}}
', + }); + + this.render('Hello!'); + + 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: '' }),