- From: Simon Pieters <simonp@opera.com>
- Date: Fri, 26 Aug 2011 22:19:55 +0200
- To: "Allen Wirfs-Brock" <allen@wirfs-brock.com>
- Cc: "Jonas Sicking" <jonas@sicking.cc>, public-script-coord@w3.org
On Fri, 26 Aug 2011 16:43:11 +0200, Allen Wirfs-Brock <allen@wirfs-brock.com> wrote: > > On Aug 26, 2011, at 4:00 AM, Simon Pieters wrote: > >> On Fri, 26 Aug 2011 09:15:20 +0200, Jonas Sicking <jonas@sicking.cc> >> wrote: >> ... >> It's ELEMENT_NODE, not NODE_ELEMENT. :-) > > so much for late night typing... > > >> >> >>> Ah, ELEMENT_NODE doesn't live on the Document interface, it lives on >>> the Node interface. So both the Node constructor and all instances of >>> the Node interface (such as document) have the ELEMENT_NODE property. >>> >>> I'm not married to having instances contain constants though. If no >>> other browsers do that, then it's likely not required for webcompat >>> and could be dropped. >> >> javascript:alert(document.ELEMENT_NODE) >> >> alerts 1 in firefox, chrome and opera. I think it's likely required for >> web compat. > > > I agree. My original point was regarding whether the replication of > constants on both interface objects and interface prototype object be > wired into WebIDL (as it current is specified) or should it be done > explicitly on a case by case basis where it is needed for web compat > for existing APIs. I don't see the advantage in introducing an inconsistency between existing APIs and new APIs here. I think it would confuse authors who are used to now constants work in existing APIs and expect them to be the same in new APIs. > For example we could allow a "static" prefix on const definitions in > which case Node might be coded as: > > interface Node { > ... > const unsigned short ELEMENT_NODE = 1; > static const unsigned short ELEMENT_NODE = 1; > ... > } > > making it explicit that ELEMENT_NODE exists "on both sides". New API's > could be encouraged to adopted the more normal ECMAScript convention and > only define the "static" constant. Could you cite an example of a constant that follows that convention? (Is the convention to define the constant on the interface object or on the prototype?) -- Simon Pieters Opera Software
Received on Friday, 26 August 2011 20:20:29 UTC