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
foreach
and template
bindings evaluate view model expression multiple times
#2480
Comments
Looks like this has been the case since 3.0.0. |
And you agree it is a bug? We surely can't have
behave differently when it comes to how (often) knockout evaluates the expression, right? I think knockout either needs to guarantee it evaluates the expression once for all those bindings (and potentially others), or expressly state that the expression may be evaluated multiple times. If the latter, I think #2455 should be re-opened and deemed not-a-bug. |
It's true we haven't previously tried to optimize how many times the binding value is evaluated. Checking the 3.5.0 tests, I found six that fail if I purposely introduce an extra evaluation (see below). But each of these is only using the number of evaluations as a proxy for updates of the binding. I think it makes sense, then, to re-tag #2455 as a feature request and not a true bug.
|
Also see: #2332 |
(Compare 3.5.0 Regression: with-binding re-invokes given function call expression instead of using returned value where it was reported that the
with
binding evaluates its view model expression multiple times.)The
foreach
binding evaluates its view model expression multiple times.https://jsfiddle.net/fastfasterfastest/y5pndfku/
The
template
binding evaluates its view model expression multiple times.https://jsfiddle.net/fastfasterfastest/vLt6zsjg/
The text was updated successfully, but these errors were encountered: