diff --git a/page.go b/page.go index 15470544..1c1e4212 100644 --- a/page.go +++ b/page.go @@ -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) { diff --git a/utils.go b/utils.go index 77ddea67..282ef23e 100644 --- a/utils.go +++ b/utils.go @@ -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) }