Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

fix: make executeJS method work properly with arrow function #969

Merged
merged 1 commit into from Jul 29, 2019

Conversation

htmlhero
Copy link
Contributor

Fixes #953.

Used another way to define IIFE that works properly with arrow functions.

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=ru.

@@ -387,7 +387,7 @@ function replaceStack(error, stack) {
}

function serializeFunc(func, args) {
return '(' + func.toString() + (_.isEmpty(args) ? '(window));' : `(window, '${args.join('\', \'')}'));`);
return '(' + func.toString() + (_.isEmpty(args) ? ')(window);' : `)(window, '${args.join('\', \'')}');`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а зачем тогда в каждом из вариантов доклеивать закрывающую скобку, если можно ее сразу после func.toString() доклеить один раз?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в каком браузере у тебя не работает текущий вариант?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такая конструкция не будет работать в любом браузере.

(() => {}())

@sipayRT sipayRT merged commit 8ac8c1e into gemini-testing:master Jul 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ExecuteJS doesnt work with arrow function
3 participants