SimonAlling / userscripter

Create userscripts in a breeze!
https://www.npmjs.com/package/userscripter
MIT License
100 stars 10 forks source link

fix: Make properties of 'e' enumerable #101

Closed SimonAlling closed 3 months ago

SimonAlling commented 4 months ago

I ran into a confusing problem in SimonAlling/better-sweclockers#264. Consider an operation with this implementation:

export default (e: {
    foo: HTMLElement,
    bar: HTMLElement,
    baz: HTMLElement,
}) => {
    for (const element of Object.values(e)) {
        console.log(element);
    }
};

One would expect that all three elements would be logged, but this operation actually does nothing at all. The reason is that the properties of e aren't enumerable, so Object.values(e) is an empty array.

While it's easy to come up with pathological examples of operations that will be broken by this change, it should be backward compatible for all practical intents and purposes.

💡 git show --color-words=.