Skip to content

Commit 3424d5b

Browse files
committed
Don't mutate options
1 parent 119a6d5 commit 3424d5b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/ferrum/frame/runtime.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,22 @@ def call(expression:, arguments: [], on: nil, wait: 0, handle: true, **options)
122122
attempts, sleep = INTERMITTENT_ATTEMPTS, INTERMITTENT_SLEEP
123123

124124
Ferrum.with_attempts(errors: errors, max: attempts, wait: sleep) do
125+
params = options.dup
126+
125127
if on
126128
response = @page.command("DOM.resolveNode", nodeId: on.node_id)
127129
object_id = response.dig("object", "objectId")
128-
options.merge!(objectId: object_id)
129-
else
130-
options.merge!(executionContextId: execution_id)
130+
params = params.merge(objectId: object_id)
131131
end
132132

133-
options.merge!(functionDeclaration: expression,
134-
arguments: prepare_args(arguments))
133+
if params[:executionContextId].nil? && params[:objectId].nil?
134+
params = params.merge(executionContextId: execution_id)
135+
end
135136

136137
response = @page.command("Runtime.callFunctionOn",
137138
wait: wait, slowmoable: true,
138-
**options)
139+
**params.merge(functionDeclaration: expression,
140+
arguments: prepare_args(arguments)))
139141
handle_error(response)
140142
response = response["result"]
141143

0 commit comments

Comments
 (0)