whatwg / webidl

Web IDL Standard
https://webidl.spec.whatwg.org/
Other
405 stars 162 forks source link

Should iterator prototype object next functions be enumerable? #739

Open domenic opened 5 years ago

domenic commented 5 years ago

https://heycam.github.io/webidl/#es-iterator-prototype-object (and the corresponding part of #720) says they are. Their ECMAScript counterparts are not.

Unlike #738, here I lean toward making them non-enumerable, as these objects are in some sense "entirely ECMAScript-like". The method in question doesn't share a location with enumerable methods corresponding to Web IDL operations.

But, I don't care that much. If we want to keep these enumerable, we should at least add a note about the intentional divergence from ECMAScript.

bzbarsky commented 5 years ago

I don't have strong opinions on this either, apart from possible implementation difficulty (e.g. Gecko currently synthesizes non-exposed IDL interfaces for the iterator, and we don't have an obvious way to make stuff there non-enumerable, iirc).

Currently

<script>
  var i = (new URLSearchParams())[Symbol.iterator]();
  document.write(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(i), "next").enumerable);
</script>

shows true in all browsers, fwiw.

bzbarsky commented 5 years ago

Ah, I guess Gecko has a [NonEnumerable] thing we added for maplike/setlike things, so implementing whatever we want would not be hard here.