Skip to content

Commit d692103

Browse files
committed
Failing test for concatenated classes on contextual glimmer components
1 parent 4d45b94 commit d692103

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

packages/@ember/-internals/glimmer/tests/integration/components/angle-bracket-invocation-test.js

+38
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,44 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {
783783
});
784784
}
785785

786+
'@test merges class attribute with `...attributes` in yielded contextual component ("splattributes")'() {
787+
this.registerComponent('foo-bar', {
788+
ComponentClass: Component.extend({ tagName: '' }),
789+
template: '{{yield (hash baz=(component "foo-bar/baz"))}}',
790+
});
791+
this.registerComponent('foo-bar/baz', {
792+
ComponentClass: Component.extend({ tagName: '' }),
793+
template: '<div class="default-class" ...attributes>hello</div>',
794+
});
795+
796+
this.render('<FooBar as |fb|><fb.baz class="custom-class" title="foo"></fb.baz></FooBar>');
797+
798+
this.assertElement(this.firstChild, {
799+
tagName: 'div',
800+
attrs: { class: classes('default-class custom-class'), title: 'foo' },
801+
content: 'hello',
802+
});
803+
}
804+
805+
'@test the attributes passed on invocation trump over the default ones on elements with `...attributes` in yielded contextual component ("splattributes")'() {
806+
this.registerComponent('foo-bar', {
807+
ComponentClass: Component.extend({ tagName: '' }),
808+
template: '{{yield (hash baz=(component "foo-bar/baz"))}}',
809+
});
810+
this.registerComponent('foo-bar/baz', {
811+
ComponentClass: Component.extend({ tagName: '' }),
812+
template: '<div title="bar" ...attributes>hello</div>',
813+
});
814+
815+
this.render('<FooBar as |fb|><fb.baz title="foo"></fb.baz></FooBar>');
816+
817+
this.assertElement(this.firstChild, {
818+
tagName: 'div',
819+
attrs: { title: 'foo' },
820+
content: 'hello',
821+
});
822+
}
823+
786824
'@test can include `...attributes` in multiple elements in tagless component ("splattributes")'() {
787825
this.registerComponent('foo-bar', {
788826
ComponentClass: Component.extend({ tagName: '' }),

0 commit comments

Comments
 (0)