W3C home > Mailing lists > Public > www-archive@w3.org > October 2007

<!-- should be equivalent to //

From: Simon Pieters <simonp@opera.com>
Date: Mon, 22 Oct 2007 14:55:46 +0200
To: es4-discuss@mozilla.org
Cc: "www-archive@w3.org" <www-archive@w3.org>
Message-ID: <op.t0lni813idj3kv@hp-a0a83fcd39d2.belkin>

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
Received on Monday, 22 October 2007 12:56:11 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 July 2008 08:10:19 GMT