July 25, 2012 - TC39 Meeting Notes
brendan at mozilla.org
Wed Aug 1 08:09:59 PDT 2012
David Bruant wrote:
> By the way, I recall something I learned from @mathias. In Chrome:
> console.log(document.all); // shows an object in the console
> console.log(typeof document.all) // undefined
> 'all' in document // true
> console.log(!!document.all) // false
> Such a thing cannot be represented in pure ECMAScript, not even with
> proxies. I don't think there is anything that can be done in
> ECMAScript to fix this, but it's worth sharing this information.
This originated in SpiderMonkey for Firefox 1.0, see
There, I used a cheap heuristic bytecode analysis to distinguish
undetected document.all uses, which some content featured (the authors
assumed IE only; IE touched 95% market share in 2002), from property
object-detected uses. The latter must be falsy but the former could be
emulated for greater de-facto web compatibility.
Later, WebKit solved the same problem with a masqueradesAsUndefined flag
set on certain objects, rather than code analysis. This is similar to
how value objects
https://bugzilla.mozilla.org/show_bug.cgi?id=749786) can be falsy.
But notice how value objects are immutable and so compare === by
shallow-enough value. That is not how document.all works -- it's a
mutable magic/live collection.
We might end up standardizing something for value proxies or value
objects that allows JS to self-host this undetected document.all
emulation hack. No promises, and no rush.
More information about the es-discuss