Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Switching `rv-if` causes binder to set up multiple times #678
Here's the fiddle presenting the problem: https://jsfiddle.net/qzyLby25/1/
Spam "toggle state" button and observe new elements appearing which is inappropriate.
It does not matter if
My commentary on this:
in AngularJS there's
Although it's pretty interesting solution it seems to be inconsistent with binders, am I wrong?
I did a test and removed nested.bind / unbind calls inside if.routine except the bind after nested is created.
I think the reason to unbind / bind inside if routine is an optimization to avoid the nested view to be updated when its model data changes. Although is questionable since the cost to unbind/rebind may be bigger than the eventual observers calls in the nested view while it is hidden
After some time i think the optimization causes some problems. If a binder is unbound it should be totally removed and not "cached" for further use. The problem can be seen in components too. See this fiddle
We see that a unbound component keeps a state. It's not logic. The initialize function should be called any time the component is bound. If we want to keep a state we don't use