fix: no data duplication in reactive Set/Map#11200
Conversation
|
|
This breaks |
|
I was trying to see how #11222 could be fixed without reintroducing data duplication but unless we want to reimplement each one of the methods by hand we need the data in the "faux" Set since we are invoking methods on it. The simple fix would be to revert this and introduce data duplication again. |
|
Yes, all methods need to be implemented. The problem with that is that it will also break if the prototypes of any of the builtins are changed. |
|
I'll take look at this. We do already redefine the methods in |
The point is that that's exactly the bug: in init we are redefining the methods to actually call super.methodname in the set instance but since that instance has no values they are empty. We could reimplement those methods but that adds code to maintain, probably less performant code in those operations (since is not native) and no forward compatibility for a small memory gain. |
But obviously feel free to try and report back if you succeed 😁 |
|
Yeah, I get that. I feel like there is a way to use native implementation without duplication. Also this is only applicable to By the way, I think map not having those methods is actually the main issue here. Since we currently model set with map keys and there are no such methods for map keys. Maybe we can find a different approach to model the data? |
I've to investigate a bit further as I didn't check if |
Svelte 5 rewrite
Data in reactive Set/Map was unnecessarily passed back to the super class. That would mean storing the same thing twice. This PR addresses this problem and adds a couple of tests to ensure the implementation is correct.
We have discussed this earlier on Discord: https://discord.com/channels/457912077277855764/1153350350158450758/1227898085087248434, where @trueadm suggested I made a PR.
Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.Tests and linting
pnpm testand lint the project withpnpm lint