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

ES5 bind #12

Closed
Raynos opened this issue Jan 19, 2012 · 1 comment
Closed

ES5 bind #12

Raynos opened this issue Jan 19, 2012 · 1 comment

Comments

@Raynos
Copy link

Raynos commented Jan 19, 2012

bound = function () {
    return self.apply( nop.prototype && this instanceof nop ? this : ( obj || {} ),
        args.concat( slice.call(arguments) ) );
};

https://es5.github.com/#x15.3.4.5

Set the [[Construct]] internal property of F as described in 15.3.4.5.2.

https://es5.github.com/#x15.3.4.5.2

Return the result of calling the [[Construct]] internal method oftarget providing args as the arguments.

https://es5.github.com/#x13.2.2

Return obj.

Basically your code always returns the return value of the bound function and doesn't handle cases like

new ( (function () {
  return undefined;
}).bind(lulz, args) ) !== undefined;

Here the return value of invoking new (and [[Construct]]) on the bound function should be that the new instance is returned, not the return value of the bound function.

Again see es5-shim for implementation.

@olivernn
Copy link
Owner

Included in the latest version

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

2 participants