Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

thousand
Copy link
Contributor

This PR resolves an issue where a type attribute, passed in a component invocation, would not correctly override the type 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 the setAttribute opcodes to apply the type 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's attributeBindings. A second special case exists in the ComponentElementOperations 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" the type 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 the type attribute because we know it will be appropriately re-ordered at runtime.

Closes emberjs/ember.js#18232

@tomdale tomdale requested review from rwjblue, pzuraq and Serabe October 16, 2020 21:00
@tomdale tomdale added the bug label Oct 16, 2020
@rreckonerr
Copy link
Contributor

rreckonerr commented Oct 16, 2020

closes #1176
related PR #1177

Mentioning these ☝️ so we could close them after this PR gets merged.

@thousand Thank you for taking care of this issue! Beautiful PR :)

@pzuraq
Copy link
Member

pzuraq commented Oct 16, 2020

Looks good, thanks for fixing this!

@chancancode
Copy link
Contributor

Great commit message, thank you for providing the context!

@chancancode
Copy link
Contributor

@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.

@tomdale
Copy link
Contributor

tomdale commented Oct 20, 2020

@rreckonerr Does this look good to merge?

Copy link
Contributor

@rreckonerr rreckonerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!
:shipit:

@Serabe Serabe removed their request for review October 20, 2020 16:56
@Serabe
Copy link
Member

Serabe commented Oct 20, 2020

Haven't worked with Ember for a while now, so my review is not needed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Angle bracket component with splattributes not correctly merging attributes
6 participants