ES accessor usage guidelines (Was: Map/Set.prototype.size)

Allen Wirfs-Brock allen at
Mon Oct 15 18:14:44 PDT 2012

On Oct 15, 2012, at 2:41 PM, Brendan Eich wrote:

> Yehuda Katz wrote:
>>    * get/set accessor may have effects on 'set' (see the DOM) but
>>    only on the receiver object (and unobservably, any children that
>>    become garbage, e.g. when trimming .length on an array-like).
>> DOM methods like `innerHTML=` seem to violate this particular wording (but perhaps not the spirit?)
> Definitely the spirit!
> That's one of those "children become garbage" cases, unless I misunderstand your point. "The receiver" for .innerHTML includes all descendants.

It may be observable in another way:
capture a reference to an existing inner element, then use innerHTML to change the parent element's  inner element collection.  Then use the original captured reference to navigate to its original parent.  I'm not sure what innerHTML actually does in this case, but most alternatives would make it either directly or indirectly observable  via the captured element reference that the original parent has been modified via innerHTML.

By my statement of the design guideline, innerHTML should not be an accessor.  However, it is legacy and I was only accessing for guidelines for use in EcmaScript standards.  It would be nice if HMTL APIs used the same guidelines but that isn't something that TC-39 could enforce, even if we wanted to.


More information about the es-discuss mailing list