classes and enumerability
brendan at mozilla.org
Wed Dec 24 21:34:11 PST 2014
Boris Zbarsky wrote:
>> -- so I think the right attack is on the quirky DOM.
> I think the fundamental assumption that the DOM is "quirky" is broken.
Something is quirky if we want mostly-consistent non-enumerability of
proto-methods/accessors. Either core built-ins, or DOM. Sorry if
"quirky" sounds pejorative, in JS contexts its common enough that what
I'm trying to get at is somewhere between unusual and exception-not-rule.
> The DOM is what it is. It dates back on the web just as far as ES
> does. It was largely implemented (certainly in terms of its ES
> bindings) by ES engine implementors.
Hey, it's me, the JS perpetrator, here :-P. There was no "ES" when I
made DOM level 0 (not called that till much later). It was all just JS
(spelled out) then. As I noted last time (including how my memory may be
failing me), *I'm* the idiot who made DOM proto-methods enumerable. I
think it was mostly an accident; I don't remember a strong rationale.
Note that I did have a rationale for non-enumerability of built-in class
proto-methods: for-in utility maximization.
> The "us vs them" mentality I see so much of on this list is very
> discouraging, honestly.
I assure you I was not suffering from us v. them or multiple
personalities back then! :-P
Seriously, the main problem over time has been W3C vs. Ecma, but I'm not
blaming the standards bodies (only or mostly). It's a separation of
concerns that mixed badly with Java heads, XML heads, and the IE
Back to the present: we have to pick a "default" setting. I think
non-enumerability wins, as noted. Can we move forward?
>> Are there some DOM prototype methods/accessors that are non-enumerable?
> Not in the Web IDL spec or in Gecko or IE as far as I know.
> I believe toString on things like HTMLAnchorElement is not enumerable
> in Chrome and Safari. See
> I'm not aware of anything else in the "DOM" that's not enumerable.
Anyone have the jwz nostalgia releases of old browsers such as Netscape
3? Would be fun to poke at some of the old (buggy, shuder) ur-DOM.
More information about the es-discuss