[whatwg/webidl] No consistency of enumerable in the `next` method (Issue #1073)

I run some test from WPT on a polyfill of mine
And one of the test made sure that the `next()` method was enumerable.
My polyfill isn't exact 100% compatible but it's just good enough to get the job done...

I tough to my self... how come that it's not compliant to my generator function that i'm using...? it's not like I'm reinventing the hole Iterator class with next, throw, return methods... I'm using something like: `class Polyfill { *values() {...} }`

So i run some test agains on some built in classes that exist on the web/js and run this test
```js
function * foo() {}

for (const Klass of [Headers, URLSearchParams, Array, Map, Set, Uint8Array]) {
  const iterator = new Klass().values()
  const prototype = Object.getPrototypeOf(iterator)
  const descriptor = Object.getOwnPropertyDescriptor(prototype, 'next')
  console.log(descriptor.enumerable)
}

const prototype = Object.getPrototypeOf(Object.getPrototypeOf(foo()))
const descriptor = Object.getOwnPropertyDescriptor(prototype, 'next')
console.log(descriptor.enumerable)
```

yields: (2) true, (5) false

How come that some `next()` methods are enumerable and some are not? it's so confusing and inconsistent. when should they be enumerable and when shouldn't they?
could this not please be normalized through out everything that is iterable to make life easier and more consistent?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1073

Received on Thursday, 2 December 2021 20:31:12 UTC