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

support older JSC; fixes #2, closes #4, closes #1 #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

leonardpauli
Copy link

@leonardpauli leonardpauli commented Jun 3, 2018

fixes #2, closes #4, closes #1

  1. using babel-preset-env with targets safari 6 (with upgraded @babel/cli)
  2. proper Function+arguments workaround
// func.apply(void 0, ...args) doesn't work with some
// special functions in older JSC versions (eg. OSX 10.11)
//  - use Function instead of eval
//    see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
//  - beware of arguments gotchas
//    see https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
const args = [structPtr, selector]; [].push.apply(args, arguments);
const argsStr = args.map((_, i)=> `args[${i}]`).join(',');
return Function(`"use strict";return function (fn, args) { return fn(${argsStr}) }`)()(func, args);

I'm running El Capitan for "reasons", and many other have had this issue. This is a more robust and less hacky way than the previous attempts. My main issue which this solves (tested by npm link):

skpm/sketch-module-web-view#51 and
skpm/sketch-dev-tools#24

also: airbnb/react-sketchapp#106

…on#1 // using babel-preset-env with targets safari 6 + Function+arguments workaround
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

Successfully merging this pull request may close these issues.

Doesn't work on older JavascriptCore versions
1 participant