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

Twice objects invalidation in bindings #4430

Closed
AlexxNB opened this issue Feb 19, 2020 · 3 comments
Closed

Twice objects invalidation in bindings #4430

AlexxNB opened this issue Feb 19, 2020 · 3 comments

Comments

@AlexxNB
Copy link
Contributor

AlexxNB commented Feb 19, 2020

When I bind the object with child component's property and use reactive declaration with it - the reactive declaration will run tripple - once on mount(it is correct) and then runs twice, but shouldn't.

Example in REPL(open the console):
There are two bindings with object and primitive type. Primitive binding doesn't run reactive statement at all, but object's binding runs twice.

https://svelte.dev/repl/1dd6381bdcbd4e179dedc6109e73ab14?version=3.18.1

Before version 3.16.5, binding with object did run statement once (after initialization one).

https://svelte.dev/repl/1dd6381bdcbd4e179dedc6109e73ab14?version=3.16.4

Expected behavior:
As I think, binding with object shouldn't invalidate object at all. Like primitive bindings.

@Conduitry
Copy link
Member

This sounds similar to #4265.

@gobeli
Copy link

gobeli commented Feb 20, 2020

Seems to be the same issue, if you change the svelte version in the #4265-REPL to 3.16.4, it works as expected:
https://svelte.dev/repl/b0204a06a3f24ede8850017c8b20b998?version=3.16.4

So, not 100% sure how everything works, but the problem seems to be here:
https://github.com/sveltejs/svelte/pull/4101/files#diff-2ce99d96b123c4afb3b3a0e72e3a8ea1R77

If $$.dirty is reset before calling the update function of the component, make_dirty will push the component to the dirty_components again:

function make_dirty(component, i) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
}

@peterbabic
Copy link

I have also come up with REPL containing comments and notes, maybe not exactly useful but I have decided to share.

https://svelte.dev/repl/eaf17544e7ab403a9990736ccce83a59?version=3.19.1

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

No branches or pull requests

4 participants