W3C home > Mailing lists > Public > www-style@w3.org > June 2013

[cssom] Idiom for representing at-rules containing properties?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 27 Jun 2013 14:54:18 -0700
Message-ID: <CAAWBYDDLT25y4GbuVsUp-xrFCqWxKTiUjkj7mx0oDnL6iFyFgA@mail.gmail.com>
To: www-style list <www-style@w3.org>
When representing an at-rule that contains a set of specialized
properties, what's the right idiom for the IDL?

CSSPageRule currently exposes a .style attribute which holds all the
properties.  CSSFontFaceRule just exposes the properties directly as
attributes on the at-rule object (as does CSSCounterStyleRule, but
that's because I just copied @font-face).

I think that using .style makes sense when the set of properties is
large and ever-growing, like it is for normal CSS properties.  The
CSSStyleDeclaration interface makes it at least somewhat more
convenient to determine what properties are actually set, at least
over the alternative of querying every possible attribute to see if
it's null or not.

On the other hand, when the set of properties is small and
rarely-growing, like in @page or @font-face, I think it makes the most
sense to just expose them directly.  You'll much more rarely want to
interact with the properties "generically", and even if you do, it's
not hard to quickly iterate through them all.  The extra indirection
of a .style object seems unnecessary, as does exposing all the
additional machinery for iterating/adding/removing rules by index.

So, I think it's best to settle on the CSSFontFaceRule idiom, and
change CSSPageRule accordingly.  (@page's OM is already broken; Simon
has a bug on it
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=22500>.)

~TJ
Received on Thursday, 27 June 2013 21:55:06 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:12 UTC