Re: [css-background] Order of properties in background shorthand

Tab Atkins Jr. <jackalmage <at> gmail.com> writes:

> On Thu, May 31, 2012 at 2:50 PM, Joe Thomas <joethomas <at> motorola.com> 
wrote:
> > I will try to explain the IE6 issue with an example.
> >
> > Assuming that we have a CSS3 UA and it generates the background shorthand
> > property in getComputedStyle in the following order
> >
> > red border-box url(dummy://test.png) 50% 50% / cover.
> >
> > And assuming that the server feeds this generated result from CSS3 Browser
> > to a CSS2.1 compatible browser like IE6. IE6 fails to parse even those
> > properties which it supports in background shorthand.
> > In the above case, IE6 parses only background-color correctly as it comes
> > before newly introduced properties. IE6 stops parsing whenever it encounters
> > an unsupported property-value like border-box in the above case.
> >
> > At the same time, if we restrict the order of background shorthand
> > properties generated by a CSS3 UA in such a way that CSS2.1 properties comes
> > before the newly introduced properties in CSS3, then IE6 parses all the
> > CSS2.1 properties correctly and discards the new properties which are at the
> > end.
> >
> > So if we change the above order to "red url(dummy://test.png) 50% 50% /
> > cover border-box", IE6 parses bg-color, bg-image and bg-position correctly
> > and discards the rest. So with this new order, IE6 can parse atleast all the
> > properties it supports.
> >
> > Please let me know whether that make sense.
> 
> So you're saying that you're serializing property values in one
> browser, sending them to the server, and later using them to style
> other pages in another browser?
> 
> That seems pretty odd, if so.  Can you clarify?
> 
> If IE6 actually does treat that declaration as valid, and just ignores
> everything from the first thing it doesn't recognize, that's *really*
> incorrect behavior.  No compliant browser does that - the specs very
> clearly state that you should throw away the whole declaration,
> *precisely* because of this kind of bad behavior.
> 
> Anyway, the correct solution, if you are indeed doing the weird thing
> there, is to parse it yourself and serve only the parts that IE6
> actually understands.

The example Joe Thomas gave isn't the same one that was originally brought up in 
a webkit bug.  The problem is that copy/paste won't work between browsers.  For 
example, if you copy from a trunk version of Chrome (canary) in an older version 
(stable), the whole declaration will get thrown away since the older version 
doesn't recognize part of the property.

The original example is also pretty common.  E.g., suppose you're composing an 
email in a rich text web mail site.  You could paste some HTML into your email 
and save a draft on one computer and try to load it on another computer.  The 
same would happen with a wiki that uses rich text.

We could always expand the background property into its specific fields when we 
generate the HTML for the clipboard, but that's really verbose.

Received on Friday, 1 June 2012 17:10:32 UTC