-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUGFIX beta] Create a new hash parameter when creating a component cell #12712
[BUGFIX beta] Create a new hash parameter when creating a component cell #12712
Conversation
@@ -74,12 +74,14 @@ export function isComponentCell(component) { | |||
} | |||
|
|||
function createNestedClosureComponentCell(componentCell, params, hash) { | |||
let newHash = assign(Object.create(null), hash); |
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.
Currently, we do not use inheritance in hash
objects (AFAIK). Do we really need to introduce that here?
Also, if we do, it should use new EmptyObject()
instead (import EmptyObject from 'ember-metal/empty_object'
).
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.
I'll change it to new EmptyObject()
. Thank you for the tip!
The thing is that processing positional params adds them to hash
in place, therefore when component gets rerendered (or the component cell gets recomputed) the hash already has the value and the assertion fails. Other option would be to check that the param's name is not in the hash
or, if it is, it is not exactly the same object.
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.
I share @rwjblue hesitations about the prototype chain being the best way to resolve this.
3f6fc7a
to
d979491
Compare
|
||
assert(`You cannot specify both a positional param (at position ${i}) and the hash argument \`${positionalParams[i]}\`.`, | ||
!(positionalParams[i] in attrs)); | ||
isActiveStreamParam || !(positionalParams[i] in attrs)); |
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.
what is this assertion against active doing? it would skip all bound positional params?
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.
My fault. I checked out the file forgetting about the previous commit.
The test here only asserts that |
d979491
to
d41021f
Compare
I'll try to explain this better. The problem is that There are other options:
|
@Serabe - Thanks for the more detailed write up. Would it be possible to allow disabling the assertion after the first render? |
I can try. Is there any way inside the |
d41021f
to
7c52e37
Compare
I did something, but I still don't fully like the solution. Another solution that might work is separating the processing from the assertions. Then, we can run the assertion at each cell component level and keep the positional parameters without processing them. Finally, the processing would be done normally, as any other component. |
I added a WIP until a satisfactory solution is found. |
The current state seems better to me than adding prototypal inheritance to the
This sounds interesting to me. That way we could just process the assertions when the cell is created, right? |
Yes. OTOH, for normal component we would go through the params twice (or we get duplicated code). |
Furthermore, if we go through the separation, we need to create new arrays and hashes when nesting for the merge. Otherwise we get a bug when nesting the same closure in two different places. |
I don't see many options right now except for to copy the attributes to a new object when creating the closure. See this tweedle. Long story sort: Ember processes positional params into the attributes, but does so in place. The components being rendered depend on this. I suggest doing this quick fix (copying the attributes inside the closure) and start looking at how to change the render process so processing positional params does not happen in place. |
@Serabe Yes, I agree. Building a new object is the right model- we should do that, then revisit for optimizations later on. |
If we merge positional and hash parameters without duplicating the hash before, then we get an error when rerendering. Fixes test in emberjs#12711
7c52e37
to
4e7fe48
Compare
Done. I need to tackle a different issue on parameters before starting to work on optimizations. |
[BUGFIX beta] Create a new hash parameter when creating a component cell
Thanks @Serabe! |
If we merge positional and hash parameters without duplicating the hash before,
then we get an error when rerendering.
Fixes test in #12711