Re: 'legal' / 'important' and cascading order

On Thu, 25 Apr 1996 18:16:00 +0200, you wrote:

>Scott Preece wrote:
>>Perhaps I'm missing something - why can't you do the same thing in
>>either case?  That is, if you have weights on individual properties
>>within a rule, you can split the rule into multiple rules, one
>>containing the
>>unweighted properties and one containing the rules with a given weight.
>>The separated rules could then be treated as you suggest.
>
>You definitely can do this - in fact, it is probably the easiest and
>best way to implement per-rule weighting.

Yes. That's the solution I found meanwhile, too. When building the
rule structure I use two declaration lists: one for declarations with
priority and one for declarations without priority.

>>
>>Frankly, it seems to me we should allow the weight to be put in both
>>places, which gives the author maximum flexibility at the cost of a
>>small additional amount of work in parsing.  That's why we build tools
>>-
>>to make life easier for tool users.

This would be maximum flexibility, indeed. But will it be needed? I
still advocate one priority spec per rule.

>
>Unfortunately, it's not just a small additional  amount of work in
>parsing - it can make the cascade considerably less efficient.  Consider
>this:
>
>H1 {
>	font-size: 12pt;
>	font-weight: bold !important;
>	text-align: left;
>	text-decoration: underline !important;
>	font-family: Arial
>}
>
>This will get split into five declarations, unless you do some resolving
>of rules with identical selectors, or keep up to three copies of a
>grouping at the same time during parsing (for important, legal and
>normal), either of which is not necessarily just a small amount of work.

No. It is split into two declaration lists:
{
	font-size: 12pt;
	text-align: left;
	font-family: Arial
}
and
{
	font-weight: bold !important;
	text-decoration: underline !important;
}
> It also confuses the issue of parsing even a bit more to have the
>"!important" token at the end of the value - it would have been much
>easier to parse had these attributes been set at the beginning of each
>declaration, e.g.
>	!important font-weight: bold;
>

I would expect a !important spec rather at the beginning, too.
At least one is used to things like:

	IMPORTANT: Before opening case disconnect power cord.

rather than

	Before opening case disconnect power cord. IMPORTANT!

But for the parser implementation it's the same.

>However, I personally am intensely in favor of per-group-only
>declarations, e.g. (for the style above):
>H1 !important {
>	font-weight: bold;
>	text-decoration: underline	}
>H1 {
>	font-size: 12pt;
>	text-align: left;
>	font-family: Arial	}
>
>One of the goals of CSS is, I believe, to keep the cost of an initial
>implementation low; I think it's wasteful to add this very small
>convenience that probably won't be used much anyway, when the
>implementation cost is non-trivial.

I agree.

Regards

Wolfgang
Buero fuer Software-Entwicklung           Email: rieger@bse.de
                                          WWW  : http://www.bse.de/
Rosenheimer Str. 214                      Phone: +49 89 497738	
81669 Munich, Germany                     Fax  : +49 89 497738

Received on Friday, 26 April 1996 10:09:18 UTC