-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
In my Ember 3.10 app, I have a button component that has tageName: '' set, and then in the template, I'm using splattributes. I'm getting some unexpected behavior when I try to override the attributes.
Below are some code snippets to explain it, but you can see it in detail in my repository here.
Here is my button component:
import Component from '@ember/component';
export default Component.extend({
tagName: ''
});and template
<button type="button" data-test-id="button" ...attributes>
{{yield}}
</button>If I use my button component by itself, the data-test-id attribute is overriden correctly, but the type attribute is still using the component's default of "button":
<XButton type="submit" data-test-id="submit-btn">Save</XButton >
{{!-- generated HTML --}}
<button type="button" data-test-id="submit-btn">Save</button>If I'm yielding it out with the component template helper, it does not correctly override either of them:
<form>
{{yield
(
hash
submit=(
component
"x-button"
data-test-id="submit-btn"
type="submit"
)
)
}}
</form>
{{!-- generated HTML --}}
<form>
<button type="button" data-test-id="button">Save</button>
</form>This doesn't seem correct to me. It seems that at least in the scenario where I'm using the component directly, it should override all of the attributes. The component helper scenario might make sense if it's only passing component properties and not element attributes.