You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rv-if going to falsy doesn't destroy elements, it seems to just remove them from DOM and keep in memory.
STR:
set rv-if to truthy, binder's function should be called
set rv-if to falsy, nested elements should be removed from DOM
set rv-if to truthy again, binder function is called on same element as previously
When rv-if turns to truthy then it readds nested elements. However, binder (checked only one-way binders) setup function is being called as many times as rv-if is switched to truthy state.
Spam "toggle state" button and observe new elements appearing which is inappropriate.
It does not matter if rv-if was truthy or falsy from the beginning which can be seen here: https://jsfiddle.net/gzyL2wnd/
My commentary on this:
in AngularJS there's ng-show (hiding elements using CSS) and ng-if (removing elements). Here rv-if seems to be something inbetween, because it removes elements but readds them instead of recreating.
Although it's pretty interesting solution it seems to be inconsistent with binders, am I wrong?
The text was updated successfully, but these errors were encountered:
That's an interesting case. I do not have a direct answer, but as I see it you should implement unbind function on your binder to correctly handle the unbinding.
I did a test and removed nested.bind / unbind calls inside if.routine except the bind after nested is created.
The tests passes and the behavior of this issue is not seem.
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 rv-if
rv-if
going to falsy doesn't destroy elements, it seems to just remove them from DOM and keep in memory.STR:
rv-if
to truthy, binder's function should be calledrv-if
to falsy, nested elements should be removed from DOMrv-if
to truthy again, binder function is called on same element as previouslyWhen
rv-if
turns to truthy then it readds nested elements. However, binder (checked only one-way binders) setup function is being called as many times asrv-if
is switched to truthy state.Fiddle
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
rv-if
was truthy or falsy from the beginning which can be seen here: https://jsfiddle.net/gzyL2wnd/My commentary on this:
in AngularJS there's
ng-show
(hiding elements using CSS) andng-if
(removing elements). Hererv-if
seems to be something inbetween, because it removes elements but readds them instead of recreating.Although it's pretty interesting solution it seems to be inconsistent with binders, am I wrong?
The text was updated successfully, but these errors were encountered: