This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27381 - Basing Object.observe() for IDL objects on internal slots
Summary: Basing Object.observe() for IDL objects on internal slots
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on: 27354
Blocks:
  Show dependency treegraph
 
Reported: 2014-11-20 15:11 UTC by Anne
Modified: 2016-06-02 21:04 UTC (History)
7 users (show)

See Also:


Attachments

Description Anne 2014-11-20 15:11:14 UTC
Once we have internal slots, and define things in such a way that e.g. innerHTML does not use them, could we perhaps base whether Object.observe() works for a given IDL attribute on whether or not it declares an internal slot? That would be rather nice.
Comment 1 Hemanth.HM 2014-11-20 15:15:03 UTC
+1
Comment 2 Olli Pettay 2014-11-20 15:21:54 UTC
Still sounds like a possible performance nightmare, at least given the current implementations.
"slot" in this case is quite faraway from JS engine internal slots, so
whenever the internal state, which implementations calculate often lazily when
the someone calls the JS getter to access the state, changes, implementation would need to check if there are observers, and then synchronously inform JS engine about the state.

And why would innerHTML behave differently to some other attributes?
Comment 3 Anne 2014-11-20 15:25:14 UTC
innerHTML does not need an internal slot as it can be computed based on the tree (innerHTML doesn't represent a primitive). Therefore Object.observe() would not work for it.
Comment 4 Olli Pettay 2014-11-20 15:31:25 UTC
That still doesn't explain why innerHTML wouldn't be observable.
Why would certain attributes behave differently? Does a js author need to look at
the specs all the time to see whether the attribute he/she is going to use can be
observed.

It is like MutationObserver could observe changes to only certain attributes but not to some others.
Comment 5 Boris Zbarsky 2014-11-20 15:46:27 UTC
We could think about it.

The requirement to _actually_ have an internal slot (to have the old value available) as opposed to conceptually having an internal slot as a specification device should not be made lightly, because it can affect the ability of engines to space-optimize.
Comment 6 Domenic Denicola 2016-06-02 21:04:22 UTC
Object.observe is dead.