-
Notifications
You must be signed in to change notification settings - Fork 192
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
Fix splattributes handling of type attribute. #1178
Conversation
Looks good, thanks for fixing this! |
Great commit message, thank you for providing the context! |
@rreckonerr want to review this PR and check if the test coverage here seems adequate compared to your reproduction? If you spotted anything else that should be incorporated, feel free to make suggestions here or rebase+retarget your PR against this one. We will also probably want to add similar tests in ember-source as well as part of landing this in Ember. |
@rreckonerr Does this look good to merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Haven't worked with Ember for a while now, so my review is not needed. Thank you! |
This PR resolves an issue where a
type
attribute, passed in a component invocation, would not correctly override thetype
attribute in a template when applied with...attributes
.In the existing implementation, we special case the
type
attribute in two places. One is at compile time, when we reorder thesetAttribute
opcodes to apply thetype
attribute last. However, this does not address dynamic cases that are not known at compile time, such as...attributes
or legacy features such as Ember'sattributeBindings
. A second special case exists in theComponentElementOperations
class, which collects aggregate attribute values and applies them once all values are known.However, currently we do not disable the first special casing when the second will apply. This introduced a bug with
...attributes
, which relies on order to determine attribute precedence. Because we always "moved" thetype
attribute to the last position, values specified in a template could never be overridden by the invocation.To fix this, we rely on the fact that these cases are mutually exclusive and only apply one or the other. At compile time, if we see
...attributes
, we do not reorder thetype
attribute because we know it will be appropriately re-ordered at runtime.Closes emberjs/ember.js#18232