Will any new features be tied to constructors?

Kevin Smith zenparsing at gmail.com
Thu Jul 2 04:18:30 UTC 2015

> I actually do have a related question, though.  In the private state
> proposals we're talking about, how would it be observable whether the
> private slots the class defines are in fact allocated as part of the
> object's allocation or separately?

Not sure I understand the question.  If the internal shape is fixed from
birth (allocation-time), there is no way to allocate private slots

Are you suggesting that the DOM could define some magic way to dynamically
allocate private slots and supposedly hide that fact from the user?

Only if you consider object identity and "===" as meaningless : )

let el = document.createElement("foo-bar");
let Custom = class extends HTMLElement {
    private @x;
    initElement() { this. at x = 1; }
    getX() { return this. at x; }
try {
    Custom.prototype.getX.call(el); // throws a TypeError: no @x
} catch (x) {}
document.registerElement("foo-bar", Custom);
Custom.prototype.getX.call(el); // No type error, returns 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150702/2bb7361d/attachment.html>

More information about the es-discuss mailing list