Skip to content

Commit

Permalink
make SprintFnThis private
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Sep 25, 2020
1 parent 0113baf commit 84d455d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion page.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ func (p *Page) EvalWithOptions(opts *EvalOptions) (*proto.RuntimeRemoteObject, e
AwaitPromise: true,
ReturnByValue: opts.ByValue,
UserGesture: opts.UserGesture,
FunctionDeclaration: SprintFnThis(opts.JS),
FunctionDeclaration: formatToJSFunc(opts.JS),
Arguments: args,
}.Call(p)
if opts.ThisID == "" && isNilContextErr(err) {
Expand Down
3 changes: 1 addition & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ func jsHelper(name js.Name, args JSArgs) *EvalOptions {
}
}

// SprintFnThis wrap js with this, wrap function call if it's js expression
func SprintFnThis(js string) string {
func formatToJSFunc(js string) string {
if detectJSFunction(js) {
return fmt.Sprintf(`function() { return (%s).apply(this, arguments) }`, js)
}
Expand Down

0 comments on commit 84d455d

Please sign in to comment.