!document.all == true
Friday, January 25, 2008 2:22:58 PM
Just about one year later, W3C's DOM1 specification gave us two methods that made document.all obsolete, document.getElementById and getElementsByTagName. But as usual web developers had to cater for the browsers people use - and for several years onwards that meant using document.all to keep things working in IE4. We're still stuck with hundreds of thousands of legacy pages using it.
When Opera started working on implementing the DOM standard (getElementsByTagName is available since Opera 5, released in December 2000) and we all eagerly looked forward to seeing dynamic menus and fancy scripting stuff start working, it soon became pretty obvious that much of the DHTML content of the day built on document.all. So it was implemented - first as a sort of hack when we identified as IE, later always enabled.
Sometimes supporting document.all caused problems. It still does. We go through IE branches when we would rather run the standards-compatible ones. I guess Mozilla learnt from our problems when they implemented document.all some four years later. Mozilla implemented it with a twist: document.all would be there, but invisible - you couldn't test for it and decide to go down the IE branch of a script. Making an object "invisibly" present isn't possible by the ECMA-262 spec, so it is a sort of standards violation to do so - quoting developer Lars Thomas Hansen:
it requires support directly from the ecmascript engine for a non-null non-undefined non-constant object value whose boolean value is false. It's doable, and probably not too expensive, but its existence directly contradicts section 9.2 of ES-262, which requires every object value to be converted to "true"
- but apparently it has worked well for both Firefox and Safari.
In the latest snapshot of Opera 9.5 you can play with Opera's new "undetectable document.all" support. It's a BIG experiment that will change the behaviour of millions of scripts all over the web. We don't do quite what Safari or Mozilla do either, and of course we'll have to figure out whether this change improves or damages compatibility with web content in general. That's where you come in - please use this build for daily browsing if you can, we need as much testing mileage for this as practically possible.