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
I have been upgrading a medium sized app from CanJS 2.3 to CanJS 4.0. In the process, I'm removing all of the implicit scope walking. This app had a few properties that were being implicitly read from the application viewModel throughout the application without passing the properties through the component tree. This causes warnings like this one:
"public/app/environment-manager/reports/executive-dashboard/executive-dashboard.stache:44: "propertyName" is not in the current scope, so it is being read from a parent scope.
This will not happen automatically in an upcoming release. See https://canjs.com/doc/can-stache.scopeAndContext.html#PreventingScopeWalking.
Use "../../../../../../../propertyName" or "scope.find('propertyName')" instead.
No one should ever actually use "../../../../../../../propertyName" in a template. There should be a better option.
In this application, propertyName is in the application viewModel. Naively, I thought this is probably scope.root.propertyName, but the scope walking warning would have told me if this were the case.
The problem here is that scope.root is not the "root"... it's not the top-level scope in this application. scope.root actually represents the viewModel of the current component.
Here is what the scopes look like in this app:
I propose we:
add a scope.viewModel that gives what scope.root gives now
add a scope.top that gives the application viewModel (the top-most actual scope)
deprecate scope.root
The text was updated successfully, but these errors were encountered:
I have been upgrading a medium sized app from CanJS 2.3 to CanJS 4.0. In the process, I'm removing all of the implicit scope walking. This app had a few properties that were being implicitly read from the application viewModel throughout the application without passing the properties through the component tree. This causes warnings like this one:
No one should ever actually use
"../../../../../../../propertyName"
in a template. There should be a better option.In this application,
propertyName
is in the application viewModel. Naively, I thought this is probablyscope.root.propertyName
, but the scope walking warning would have told me if this were the case.The problem here is that
scope.root
is not the "root"... it's not the top-level scope in this application.scope.root
actually represents the viewModel of the current component.Here is what the scopes look like in this app:
I propose we:
scope.viewModel
that gives whatscope.root
gives nowscope.top
that gives the application viewModel (the top-most actual scope)scope.root
The text was updated successfully, but these errors were encountered: