<!-- should be equivalent to //
Simon Pieters
simonp at opera.com
Mon Oct 22 05:55:46 PDT 2007
In IE, Firefox, Opera and Safari, the character sequence <!-- in
javascript is a line comment, i.e. equivalent to //. ECMA 262 didn't
define this. AFAICT ES4 doesn't define it, either. *Many* pages on the Web
rely on this, so browsers cannot remove it for existing content.
Note that HTML cannot fix this, because <!-- is used in external js files
in the wild, and HTML doesn't have a look-in there.
I note that this behavior is incompatible with E4X, where <!-- would be
the start of an XML comment object. Unless I'm mistaken Firefox handles
this incompatibility with the ;e4x=1 switch...
Also, it seems that Firefox and Safari sometimes treat --> as a line
comment, too, but that IE and Opera don't.
Some demos:
http://tc.labs.opera.com/ecmascript/html-comments/
Is this something that can be specced in ES4? Or is the intent to require
UAs to have a switch such that they can disable the <!-- treatment for ES4
scripts, and keep it for legacy scripts? (If the latter, ES3 still needs
an update if this is going to be specced at all...)
Cheers,
--
Simon Pieters
Opera Software
More information about the Es4-discuss
mailing list