Re: CSS Mixins proposal

On Wed, Mar 23, 2011 at 3:46 PM, Garrett Smith <dhtmlkitchen@gmail.com>wrote:

> On 3/22/11, Shane Stephens <shans@google.com> wrote:
> > Hi list,
> >
> [...]
> > I think it's clear that using an @-rule in this manner is safe on pretty
> > much every browser likely to be currently in use, or at least the vast
> > majority.
> >
> Test the DOM, e.g. sheet.cssRules[0].style.length
>

I looked into sheet.cssRules[].style objects today.  The most important
result is that @mixin declarations will not impact code which uses
cssRules[].style objects.

Here are the messy details:

cssRules[].style (or rules[].style, depending on browser) objects come in
two forms:
* Internet Explorer 6 thru 9 provide objects with properties that correspond
to CSS property names.  These objects are unaffected by @mixin declarations,
except that an additional "mixin" property is created with an undefined
value.  Any code which looks for specific properties will still find those
properties; while any code which iterates through all of the properties on
the object must already be able to handle undefined values as this is how IE
represents style properties that have not been set by a style rule.
* Firefox 2, 3, 3.6, and 4; Opera 11; Safari 3, 4 and 5; and Chrome 10
provide an array of CSS properties.  This array is completely unaffected by
@mixin declarations - it remains the same length regardless of the location
of the declaration, and contains the same values.

Cheers,
    -Shane


> --
> Garrett
>

Received on Thursday, 31 March 2011 10:50:07 UTC