RE: [cssom] draft of color serialization rules


[Tab Atkins Jr.:]
> 
> On Tue, Oct 2, 2012 at 12:31 PM, Sylvain Galineau <sylvaing@microsoft.com>
> wrote:
> >>The question is how much to we want to break working pages/content? For
> example, if I thought that were feasible, I would >specify that no space
> followed commas, e.g., rgb(0,0,0) instead of rgb(0, 0, 0).
> >
> >>However, my understanding of the goals of CSSOM is that, all things
> considered, it should try to capture current practice >when it appears
> there is significant consensus towards a common behavior. At present, that
> common behavior seems use rgb() >rather than rgba() for opaque colors.
> >
> > Code that handles both correctly wouldn't be affected by choosing one
> result over the other. And new code would be simpler.
> >
> > You're of course right about code that assumes rgb() strings: that could
> suddenly start breaking.
> 
> I know from experience that, if you're using jQuery to get color values,
> and you want your website to work on IE, you have to be able to parse
> *all* of the variants - rgb/a(), hsl/a(), 3 and 6 digit hex, and named
> colors.  I had to add several of those parsing modes to an old project. :/
> 
> Because of this, I suspect that most working parsers can handle quite a
> bit, so we can choose what representation we'd like.  I'm less confident
> about their ability to handle the presence/absence of spaces between
> components.
> 
Depending on what format you use to specify your colors and how many versions
you're trying to cover then yes, it may go that far. Especially if you're
writing a library for the masses.

But I'd be less concerned about code as popular and well-tested as jQuery's
than the code written or copy/pasted by less advanced authors who rolled 
around their own web site or intranet app and assume rgb() because 
computed opaque color values is all they ever manipulate. Then we switch them 
to rgba(x,y,z,1) and things stop working. There is no shortage of code on
the web that was worked on until the point where 'it just worked' and no
further.

Spaces are another one.

On the other hand IE9 re-worked serialization to align with what Anne had
written in the CSSOM ED and the impact was surprisingly muted. There may be
less parsing than we think; or, possibly, quality libs have taken over a 
large portion of it.

Received on Tuesday, 2 October 2012 20:19:09 UTC