Comments (6)
After testing native bind
against our polyfill and the MDN polyfill, Iβm afraid I canβt replicate the issue you are having.
Native:
new (String.bind('test')) === new (String.bind('test')) // returns false
Our polyfill:
new (String.bind('test')) === new (String.bind('test')) // returns false
MDN Polyfill:
new (String.bind('test')) === new (String.bind('test')) // returns false
Native:
new (function (e) { console.log(e) }.bind(null, 'test')) // logs "test", returns Object {}
Our polyfill:
new (function (e) { console.log(e) }.bind(null, 'test')) // logs "test", returns bound {}
MDN Polyfill:
new (function (e) { console.log(e) }.bind(null, 'test')) // logs "test", returns fBound {}
Would you provide more details and perhaps a test?
from polyfill-service.
Your bind will also error when attempting to bind a native method. This is because native methods don't have a prototype
property so your bound function gets a prototype
of undefined
which then throws an error when you do the this instanceof Constructor
check.
from polyfill-service.
Sorry about my examples. As I told you built-in constructors have overloaded behavior depends how they are called .
new String('test'); //string object
String('test'); //primitive string value
Your bind implementation doesn't handle that.
String(new (String.bind(null, 'test'))); //Native bind returns 'test'
Your bind fails with error since String#toString is not generic.
from polyfill-service.
I just bumped into the issue described by @jdalton. Here's the exact message for reference:
Uncaught TypeError: Function has non-object prototype 'undefined' in instanceof check
And here's code to cause it:
RegExp.prototype.test.bind(/a/)('a');
from polyfill-service.
Added test case in https://github.com/Financial-Times/polyfill-service/blob/functionbind_test/polyfills/Function.prototype.bind/tests.js
from polyfill-service.
Lots of issues reported with our bind implementation: ref #313 and #261
from polyfill-service.
Related Issues (20)
- Adding polyfill for `Object.hasOwn` HOT 4
- Service is broken (for v2/ie11 at least) HOT 2
- The "polyfills.io" service is unavailable HOT 4
- Is there an error in the judgment criteria in Object.defineProperty? HOT 4
- Feature request: support for dialog-polyfill? HOT 1
- CONTRIBUTING.md guide question / local service running HOT 5
- Fetch is wrongly polyfilled for Chrome on iOS
- SSL Certificate of polyfill.io is not trusted HOT 4
- Issue with Webview in Android 13 Version HOT 1
- Incorrect polyfills & unexpected change of behavior 2023-12-19 HOT 4
- Broken link from github repo HOT 1
- Manager
- no-version scenario changed, maybe? HOT 6
- Is it true that polyfill.io hosting is going to be owned by a Chinese company? HOT 18
- Error loading polyfill from CDN - Cannot convert a Symbol value to a string HOT 3
- polyfill.io - 502 Bad Gateway HOT 2
- How to disclose Security Vulnerabilities HOT 4
- Polifill and google places API clash HOT 3
- Polyfill.io adding only requested features without adding additional polyfills that the browser needs
- HTML code displayed for some words in privacy policy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polyfill-service.