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

Make it work without requiring Symbol polyfill #2

Closed
andreypopp opened this issue May 5, 2015 · 4 comments
Closed

Make it work without requiring Symbol polyfill #2

andreypopp opened this issue May 5, 2015 · 4 comments

Comments

@andreypopp
Copy link
Owner

The best would be to have babel to transpile Symbol itself.

@gaearon
Copy link
Contributor

gaearon commented May 6, 2015

Same for Reflect

@chicoxyzzy
Copy link

so babel will add local polyfill but target browsers could be Symbol-ready. so we loose in performance and module size in that case

@sebmck
Copy link

sebmck commented May 6, 2015

Why use the symbol at all?

Just change:

return {
  configurable: true, // must be true or we could not be changing it
  get() {
    if (!this.hasOwnProperty(_key)) {
      this[_key] = fn.bind(this);
    }
    return this[_key];
  }
};

to

return {
  configurable: true, // must be true or we could not be changing it
  get() {
    var fn = this[key].bind(this);
    Object.defineProperty(this, key, {
      configurable: true,
      writable: true,
      value: fn
    });
    return fn;
  }
};

The current way is slower too since the overhead of the getter is going to be there every single time, regardless of your use of the private bound method.

@andreypopp
Copy link
Owner Author

@sebmck you are right, that's actually how it was implemented initially fb29744#diff-1fdf421c05c1140f6d71444ea2b27638

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

4 participants