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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.0.0-beta.12 - Custom elements instances are now different #1958
Comments
@tareqimbasher can you try with latest beta? it's possible that it's been already fixed, since this looks like a very common scenario. |
Unfortunately not in any timely manner, the latest beta (v15) requires a nontrivial change to decorator usage. That effort however is contingent on having a working app which this issue is blocking. I do see this issue in beta v14 as well. I'm hoping I can try reproducing this issue in a standalone app to see if v15 would resolve it. |
Is my expectation that a new custom element instance should be returned everytime a correct one? Regardless if it's used within a |
beta 14 can do, there shouldn't be differences between them with regards to this.
this does not result into a new instance, this will follow the standard resolution mode of If you want a new instance, use container.invoke(ViewModel) |
Got it, thank you for that last part, that is definitely different than how it was in beta.11. So just to be sure, is my expectation that a new instance should be created everytime when used in a HTML template correct? |
Aurelia does that. Is your question about your app code? |
My question is what does Aurelia do, which you've answered, thank you. I just didn't want to be expected something that the framework isn't doing by design. |
Thanks @tareqimbasher , closing this. |
@bigopon thank you for answering my questions so far but I believe this issue shouldn't be closed yet as the issue I'm experiencing remains unresolved. I have yet to complete a standalone repro to determine if the problem I described is a change in behavior or some weird glitch specific to my app code. |
Indeed, i was hasty, my apology. |
馃悰 Bug Report
Starting with 2.0.0-beta.12, something must have changed with the way custom elements are resolved. Suppose we have the following:
my-view-model.html
my-view-model.ts
result-view.html
result-view.ts
In 2.0.0-beta.11,
<navigation-controls></navigation-controls>
would be a different instance of that custom element for each rendered<au-compose component.bind="resultView">
. In 2.0.0-beta.12, they are the same instance.I looked through the changelog for 2.0.0-beta.12 and there doesn't seem to be any info about this. Looking through the commits for that release I see a few places that could have caused this but I'm far from being familiar enough with Aurelia's internals to be certain.
I've seen this as part of a fairly large project, NetPad, so I'm still trying to put together a standalone repro to demonstrate it properly but its happening with multiple custom elements, and not just in one place. On the flip side, I'm not seeing this behavior everywhere, so maybe its something to do with it being hosted inside an
<au-compose>
.In places where I'm resolving a custom element's viewmodel using the
container
, a singleton instance of theNavigationControls
viewmodel is also returned, before it was a new instance each time. UsingnewInstanceOf
gives me back a new instance ofNavigationControls
but we didn't have to do that before.Is this a known change? And is there a way to change this behavior globally in app setup?
Repro link: TBD
馃 Expected Behavior
Referencing a custom element in an HTML template should resolve a new instance every time.
馃槸 Current Behavior
Referencing a custom element in an HTML template returns the same instance every time, in some cases. I also see this new warning:
{{0}} here is
NavigationControls
for example.馃拋 Possible Solution
馃敠 Context
This affects me in that custom element scopes are now all different than what they were previously. Passing each
<navigation-controls>
a bound value like<navigation-controls val.bind="someValFromParent">
doesn't work the same because there is only one<navigation-controls>
element. This results in broken UI and alot of weird behaviors I'm still uncovering.馃捇 Code Sample
馃實 Your Environment
The text was updated successfully, but these errors were encountered: