Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anonymous functions in execute_script #230

Open
mguilmineau opened this issue Dec 20, 2018 · 0 comments
Open

anonymous functions in execute_script #230

mguilmineau opened this issue Dec 20, 2018 · 0 comments

Comments

@mguilmineau
Copy link

mguilmineau commented Dec 20, 2018

Greetings, just so you know I was running (in chromium's latest) execute_script with an anonymous function in it that referenced arguments, as such:
execute_script( "const e=arguments[0], i=(function(s){ val = arguments[1] ; ... })(e) ; ...", [ arg0, arg1] )
Turns out that while e is properly defined as taking the value of arg0, once inside the anonymous function arguments is equals to [e] i.e. what was passed to the anonymous function, not [ arg0, arg1] any longer.
That's an unfortunate side-effect of having named your arguments "arguments" I suppose. :)
My workaround was to define an extra variable taking arg1 as its value, before the anonymous function then invoke that variable from within. But ideally there's no having to worry about that array's value being overwritten at execution time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant