Descendant bindings of if, with, etc. should have a dependency on the parent condition#2234
Descendant bindings of if, with, etc. should have a dependency on the parent condition#2234
Conversation
…ency on the parent condition so that updates happen in the right order when using deferred updates.
|
With these changes, it appears that descendant bindings will have a dependency on the ancestor binding. In #2226 (comment) you voiced concern about that, but with these changes it appears that every descendant binding will be re-evaluated when an ancestor binding is re-evaluated even if the ancestor binding value doesn't change. The changes I proposed in #2226 (comment) caused dependent bindings to have a dependency, not on the ancestor binding, but on the ancestor binding value - and therefore doesn't (needlessly) re-evaluate descendant bindings if the ancestor binding value doesn't change. In the following example, the http://jsfiddle.net/fastfasterfastest/xjg6j2xr/2/ is a sample showing the current (3.4.2) behavior. It has a "compound" condition made up of two sub-conditions and you can set the sub-conditions. It shows timestamps when text nodes are (re-)evaluated. Notice how the descendant binding of the http://jsfiddle.net/fastfasterfastest/xjg6j2xr/3/ shows the same sample using the changes I proposed in #2226 (comment) - same behavior as in 3.4.2, the descendant binding of the I think with the changes proposed here, the descendant bindings of the A minor detail: |
|
Just to clarify - it is the descendant binding's value that should have a dependency on the ancestor binding's value. The descendant binding per se, or the descendant binding context, should not have a dependency on the ancestor binding. I outlined a way to implement that in #2226 (comment) and the sample http://jsfiddle.net/fastfasterfastest/0u1qx24p/13/ has that implementation. |
|
I'll try my changes with your fiddle. I'm pretty sure it will work properly. Putting the dependency in the binding context also creates a dependency in the binding values since they depend on the context. |
Yes, but doing so causes, I believe, the descendant bindings to be (needlessly) re-evaluated when the ancestor bindings' dependencies change. I may be incorrect, but if not then the descendant bindings will be re-evaluated even if the ancestor binding's value doesn't change. |
|
Looks like I still have some work to do. It works as expected with |
|
The implementation I provided in http://jsfiddle.net/fastfasterfastest/0u1qx24p/13/ and discussed in #2226 (comment) works, I believe. Unfortunately I haven't done a pull request but if you make a diff of the "custom" knockout that fiddle uses against 3.4.2 you'll see the changes. |
|
I figured out why my change works differently between the deferred/non-deferred scenarios. I've opened another issue to track it: #2240. |
|
👍 |
… so that updates happen in the right order when using deferred updates.
See discussion in #2226