{"id":15207129,"url":"https://github.com/webcarrot/proto-polyfill","last_synced_at":"2025-10-02T23:35:48.135Z","repository":{"id":57331815,"uuid":"97131608","full_name":"webcarrot/proto-polyfill","owner":"webcarrot","description":"Provide __proto__ with some limitations","archived":true,"fork":false,"pushed_at":"2018-08-30T12:59:57.000Z","size":21,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-24T08:02:13.978Z","etag":null,"topics":["babel","class","es6","ie10","ie9","polyfill","proto","static","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webcarrot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-13T14:26:55.000Z","updated_at":"2023-09-25T13:34:14.000Z","dependencies_parsed_at":"2022-09-05T08:01:01.979Z","dependency_job_id":null,"html_url":"https://github.com/webcarrot/proto-polyfill","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcarrot%2Fproto-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcarrot%2Fproto-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcarrot%2Fproto-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcarrot%2Fproto-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webcarrot","download_url":"https://codeload.github.com/webcarrot/proto-polyfill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219876112,"owners_count":16554735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","class","es6","ie10","ie9","polyfill","proto","static","webpack"],"created_at":"2024-09-28T06:22:22.025Z","updated_at":"2025-10-02T23:35:47.838Z","avatar_url":"https://github.com/webcarrot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# proto-polyfill \u0026middot; [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/webcarrot/proto-polyfill/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/proto-polyfill.svg?style=flat)](https://www.npmjs.com/package/proto-polyfill)\n\nProvide `__proto__` with some limitations\n\n## browsers that need this polyfill\n\nIn general old browsers that **not** provide legacy `__proto__` and **support** `Object.defineProperty`, `Object.getPrototypeOf`, `Object.getOwnPropertyNames`, `Object.getOwnPropertyDescriptor` and `Object.create`:\n\n- IE 9\n- IE 10\n\nIE 8 is **not** supported.\n\n### why and when\n\nIf you do things like:\n./tests/class-like.js\nor (ES6 version):\n\n```js\nclass X {\n  static get foo() {\n    return \"xFoo\";\n  }\n  get foo() {\n    return this.constructor.foo + \" by instance!\";\n  }\n}\nX.s = { s: \"x\" };\nX.f = \"X\";\nclass Y extends X {\n  static get foo() {\n    return this.__proto__.foo + \" \u003e yFoo\";\n  }\n}\nY.s = {\n  s: \"y\"\n};\nY.f = \"Y\";\nclass Z extends Y {\n  static get foo() {\n    return this.__proto__.foo + \" \u003e zFoo\";\n  }\n  get foo() {\n    return \"My special Z foo \" + super.foo;\n  }\n}\nZ.f = \"Z\";\nvar x = new X();\nvar y = new Y();\nvar z = new Z();\nconsole.log(x.foo); // xFoo by instance!\nconsole.log(y.foo); // xFoo \u003e yFoo by instance!\nconsole.log(z.foo); // My special Z foo xFoo \u003e yFoo \u003e zFoo by instance!\nconsole.log(x.constructor.s.s); // x\nconsole.log(x.constructor.f); // X\nconsole.log(y.constructor.s.s); // y\nconsole.log(y.constructor.f); // Y\nconsole.log(z.constructor.s.s); // y\nconsole.log(z.constructor.f); // Z\n```\n\n...and code produced by compliler ( babel 6.x ) not work properly in old browsers like ie9-10.\n\n## installation\n\n`npm install --save-dev proto-polyfill`\n\nAnd use like polyfill...\n\n## limitations\n\nLook at ./tests/limitations.js\n\n```js\nvar x = {\n  a: \"xa\"\n};\nfunction X() {}\nX.prototype.a = \"Xa\";\nX.prototype.cv = \"XCV\";\nX.prototype.ab = function() {\n  return \"ab:\" + this.a;\n};\nObject.defineProperty(X.prototype, \"c\", {\n  get: function() {\n    return this.ab() + \":\" + this.cv;\n  }\n});\n// no way to replace object prototype \"in place\" ?\nx.__proto__ = X.prototype;\nconsole.log(x instanceof X); // invalid log: false should true\n// but some kind emulation works\nconsole.log(x.a); // ok log: \"xa\";\nconsole.log(x.ab()); // ok log: \"ab:xa\";\nconsole.log(x.c); // ok log: \"ab:xa:XCV\";\n// normal instance\nvar iX = new X();\nconsole.log(iX instanceof X); // ok log: true\nconsole.log(iX.a); // ok log: \"Xa\";\nconsole.log(iX.ab()); // ok log: \"ab:Xa\";\nconsole.log(iX.c); // ok log: \"ab:Xa:XCV\";\n// override\nX.prototype.cv = \"XCV2\";\nconsole.log(x.c); // ok log: \"ab:xa:XCV2\";\nx.cv = \"XCV3\";\nconsole.log(x.c); // ok log: \"ab:xa:XCV3\";\n// but\nX.prototype.newProp = \"newProp\";\nconsole.log(x.newProp); // invalid log: undefined should \"newProp\";\n```\n\n### Pseudo Symbol()\n\nPseudo `Symbol()` props are skipped (core-js Set polyfill use it)\n\n### Object.setPrototypeOf\n\nOnly emultation\n\n### Object.getPrototypeOf\n\nOverride to make super() work in Babel 7\n\n## tests\n\n`./tests/index.html`\n\nPR welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebcarrot%2Fproto-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebcarrot%2Fproto-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebcarrot%2Fproto-polyfill/lists"}