We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Some features cannot be fully implemented, and it would be helpful to have a consistent way of telling.
I'm thinking something along the lines of the following:
export const key = Symbol.for('_polyfilled'); export function markPolyfilled(thing, name) { if (thing.hasOwnProperty(key)) { thing[key].push(name); } else { Object.defineProperty(thing, key, { value: [name], enumerable: false, configurable: false, writable: false, }); } } export function isPolyfilled(thing, name) { return thing.hasOwnProperty(key) && thing[key].includes(name); }
Using Symbol.for() makes it easily accessible in other scripts/modules without importing.
Symbol.for()
Using Object.defineProperty() with enumerable set to false makes it so Object.keys() and Object.entries() won't list this.
Object.defineProperty()
enumerable
false
Object.keys()
Object.entries()
Having an array allows for multiple records of polyfills on the same thing without conflict.
const obj = { num: 42 }; markPolyfilled(obj, 'foo'); markPolyfilled(obj, 'bar'); console.log({ foo: isPolyfilled(obj, 'foo'), bar: isPolyfilled(obj, 'bar'), bazz: isPolyfilled(obj, 'bazz'), keys: Object.keys(obj), symbols: Object.getOwnPropertySymbols(obj), });
The text was updated successfully, but these errors were encountered:
I've added the markPolyfilled() to utils.js and handle it automatically in polyfillMethod(), polyfillGetterSetter(), and overwriteMethod().
markPolyfilled()
utils.js
polyfillMethod()
polyfillGetterSetter()
overwriteMethod()
Making this widely supported is largely a matter of re-writing a ton of polyfills that are more direct. Will take some effort to do so.
Sorry, something went wrong.
shgysk8zer0
No branches or pull requests
Some features cannot be fully implemented, and it would be helpful to have a consistent way of telling.
I'm thinking something along the lines of the following:
Using
Symbol.for()
makes it easily accessible in other scripts/modules without importing.Using
Object.defineProperty()
withenumerable
set tofalse
makes it soObject.keys()
andObject.entries()
won't list this.Having an array allows for multiple records of polyfills on the same thing without conflict.
Example
The text was updated successfully, but these errors were encountered: