W3C home > Mailing lists > Public > www-style@w3.org > August 2012

Re: Comment syntax

From: Greg Houston <gregory.houston@gmail.com>
Date: Mon, 27 Aug 2012 19:04:26 -0500
Message-ID: <CAOtq01Bt6L+rpu-sMOOpiVYUOLWe2g-qpN-sbiphi5KgkQyBJw@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "Kang-Hao (Kenny) Lu" <kanghaol@oupeng.com>, "Zachary “Gamer_Z.” Yaro" <zmyaro@gmail.com>, Liam R E Quin <liam@w3.org>, WWW Style <www-style@w3.org>, "Jens O. Meiert" <jens@meiert.com>
>> On Mon, Aug 27, 2012 at 5:27 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> The problem I'm scared of is stylesheets that *work* today, but have
> been minified in such a way that they'll break if we make // a "real"
> comment.
>
> For example, the following stylesheet works fine today:
>
> foo {
>   background: white;
>   //background: linear-gradient(white, silver);
>   color: red;
> }
>
> The second declaration is "commented out", because the CSS parser
> barfs upon seeing the / and recovers by throwing away everything until
> the next ";" character.
>
> When minified, it works exactly the same way:
>
> foo { background: white; //background: linear-gradient(white, silver);
> color: red; }
>
> However, if we change // from being invalid syntax to being a
> line-terminated comment, this minified stylesheet suddenly changes
> meaning, and the 'color' declaration is thrown out (along with the
> entire rest of the stylesheet, if anything follows it).
>
> This is why I'd like to see compat data for this.  There is *nothing
> wrong* with naively minifying it like this today, so there may be
> significant amounts of stylesheets which would break if we changed the
> meaning of //.
>
> We could avoid this hazard by instead making // just a "blessed" way
> to comment out properties, but it already does that job just fine, so
> there doesn't seem to be any value in actually recognizing it in the
> parser.
>
> ~TJ

I'm amazed after all these years I haven't accidentally realized I
could comment out a single property with //. Every time I start to do
it, which is often, I tell myself, "Ope, can't do that". If using //
as an actual single line comment proved to break too much existing
content, rather than bless the accidental and incomplete
"functionality" // currently has, I would rather see something like
/// used that actually does what coders expect from a single line
comment, which is to comment out everything on that line.

Just on a side note and I'll drop out of this conversation, using //
to comment out a property is obviously a CSS hack, and one that I know
I've never seen documented. In general does supporting hacks fall into
the scope of backward compatibility?

G.
Received on Tuesday, 28 August 2012 00:04:55 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:58 GMT