-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: simplify and use correct ctx in withCtx
- Loading branch information
Showing
8 changed files
with
44 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
// These are only used in esm-bundler builds, but since exports cannot be | ||
// conditional, we can only drop inner implementations in non-bundler builds. | ||
|
||
import { ComponentInternalInstance } from '../component' | ||
import { withCtx } from './withRenderContext' | ||
|
||
export let currentScopeId: string | null = null | ||
|
@@ -23,14 +22,13 @@ export function popScopeId() { | |
|
||
export function withScopeId(id: string): <T extends Function>(fn: T) => T { | ||
if (__BUNDLER__) { | ||
return ((fn: Function, ctx?: ComponentInternalInstance) => { | ||
return withCtx(function(this: any) { | ||
return ((fn: Function) => | ||
withCtx(function(this: any) { | ||
pushScopeId(id) | ||
const res = fn.apply(this, arguments) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yyx990803
Author
Member
|
||
popScopeId() | ||
return res | ||
}, ctx) | ||
}) as any | ||
})) as any | ||
} else { | ||
return undefined as any | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
withCtx
appears to call the passed function with anull
this
. Is that intended? I only ask as this function preservesthis
but wrapping it inwithCtx
destroys that.cc @yyx990803