Experimental implementation of Object.observe & JS Utility library now available

Andrea Giammarchi andrea.giammarchi at gmail.com
Sun Aug 19 00:40:02 PDT 2012

The Object owner is a bit inconsistent concept in JS + DOM world.

document.body.innerHTML = '<div><a hraf="#">link</a></div>';

is a very basic example ...

   1. was the user owning the document.body ? I don't think so, body is
   created in any case even if not specified in the markup
   2. was the user able to set mutation event on that element? well, yes,
   even without ownership
   3. is the user the owner of that link? I don't think so, the DOM is the
   owner, not the user, who simply relies the fact Mr DOM will create an
   object for him
   4. is anyone else able to observe mutation of any element? Yes, 'cause
   there's no way for a user to mark a DOM node as his/her own

Proxy aren't usable as DOM nodes, are they? I cannot
el.appendChild(myOwnProxyOfAnElement) also because others would be able to
attach mutation events or observe changes in that node or, even worst,
invalidate/remove/destroy my own proxy once document.body.innerHTML = "";
is invoked ... what would be the Proxy, usable as DOM element (in a
parallel universe), exact behavior?

Object.observe might result into an "easy to abuse" pattern but in JS world
we have too many objects that we don't own by default but we would like to

I understand that knowing explicitly which property we want to observe,
something possible with Object#watch, could make things more reasonable (
we need to know in advance the property so we kinda feel like owning it )
but Object#watch has its own problems too with ownership, multiple watches,

Object.observe seems to be the best compromise from both worlds, imho.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120819/e70d651f/attachment-0001.html>

More information about the es-discuss mailing list