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
fix(core): Fix scope capturing via captureContext function (#10735)
In #9801, we
introduced a regression that if you pass a function as `captureContext`
to capture methods, the returned scope is not used.
The cause for this was a confusion on my end, based on the slightly
weird way this works in `scope.update(fn)` - we don't actually merge
this or update the scope based on the return value of `fn`, but `fn`
receives the `scope` as argument, does nothing with the return type of
`fn` and just returns it - which we didn't use, because I assumed that
`scope.update` would actually return the scope (also, the return type of
it is `this` which is not correct there).
This PR changes this so that the returned scope of `fn` is actually
merged with the scope, same as if you'd pass a `scope` directly - so
this is fundamentally the same now:
```js
const otherScope = new Scope();
scope.update(otherScope);
scope.update(() => otherScope);
```
(which before would have had vastly different outcomes!)
I added a bunch of tests to verify how this works/should work.
Fixes#10686
0 commit comments