!document.all == true
Friday, 25. January 2008, 14:22:58
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.
Feedback on JavaScript problems specific to this build welcome in the desktopteam blog, in comments below or as bug reports!








HeroreV # 25. January 2008, 20:44
In both Firefox quirks mode and Opera 9.5, the test for ("all" in document) is true. I know the "in" operator isn't used very much, but If Opera is going to differ from Firefox, it might as well do a better job of hiding document.all than Firefox does.
porneL # 25. January 2008, 20:47
Dashiva # 25. January 2008, 21:50
xErath # 25. January 2008, 21:52
kamalesh # 25. January 2008, 21:55
I'm having good luck with Build 4622 in my daily browsing, except for a couple sites I'll note at the ODT blog.
Can you explain for us any ramifications of cloaking document.all relating to user-agent strings that Opera changes for a few sites like WSJ.com and MSNBC.com...??
<porneL> just asked also, I think.
hallvors # 25. January 2008, 22:15
kamalesh: document.all basically doesn't relate to user-agent strings at all, except that some scripts use it to "detect" IE in a simpler way than parsing the user-agent string.
Zibi1981 # 25. January 2008, 23:35
I'm using Opera (downloaded as a shared qt rpm-file) 9.5 Beta 2 build 1772 on Mandriva 2008.0. The top of the site seems messed up.
scipio # 26. January 2008, 10:51
Originally posted by hallvors:
Any details on the differences?fearphage # 26. January 2008, 19:59
returns a true value in opera: "[object HTMLCollection]"
It would be beneficial if there was no incarnation of document.all that could return a true value. It would also be sensible to hide it until masked as IE or in quirksmode as suggested.
xErath # 26. January 2008, 21:08
nah.. it's return's an object which always evaluates to false, but toString returns what you see.
fearphage # 27. January 2008, 02:32
hallvors # 27. January 2008, 09:56
hallvors # 27. January 2008, 10:03
http://www.mandrivaclub.pl/forum/templates/strefa/rekl.js . Actually it's a typical example of a sniffer that will now return a different result (and a fairly braindead sniffer at that, since it first "detects" us as Opera, then proceeds to overwrite that result by "detecting" either IE, Netscape or Mozilla..). I don't have time to investigate the problems right now but will follow up.
xErath # 28. January 2008, 01:24
metcomm # 28. January 2008, 12:12
blaberus # 30. January 2008, 14:30
a Russian site about Opera with the same news looks odd now ))
http://forum.myopera.net/showflat.php?Cat=&Board=newsuser&Number=37654
fearphage # 30. January 2008, 15:18
GoJoeGo # 30. January 2008, 17:56
tarquinwj # 30. January 2008, 19:26
Originally posted by hallvors:
They do, and because they use repeated "if" instead of "else if", they now detect Opera as "MO" instead of "OP". However, that function never gets used, so the browser version is always undefined, no matter what browser you use. Must be something else for us to look into
Edit:
Got it. Known issue. Already fixed in core. Extra } in one of the stylesheets causes the rest of it to be ignored.
fearphage # 31. January 2008, 00:03
GoJoeGo # 31. January 2008, 15:35
Zibi1981 # 2. February 2008, 10:11
fearphage # 4. February 2008, 19:47
@Hallvord: Any chance that window.opera will be cloaked when masking as FF/IE?
hallvors # 4. February 2008, 22:40
We don't currently plan to hide window.opera either. I should probably have a look and try to find sites where that might make a difference.
fearphage # 5. February 2008, 01:05
shaver # 5. February 2008, 18:35
hallvors # 6. February 2008, 12:51
I'll be a bit more detailed on what exactly we do (and what Mozilla/Safari appear to do) in the future when I know if our implementation will stay what it is.