Apropos this test case:
http://test.csswg.org/suites/css2.1/20110323/html4/keywords-000.htm
The p
element matches three rules. The first rule sets the background to green, the second one sets the background to initial value (because the quoted string 'red' is not recognized as a keyword) and the third one sets the foreground color.
This test fails in CSSBox because, when analysing a matching p
element, the analyzer sets the background property to its initial value without considering if it has been set in another rule.
From my current understanding of jStyle and CSS spec, this could be solved in two ways:
During analysis, set the initial value of a property only if it has not been specified in another rule that matches the current element.
Never set the initial value for any property. Let the layout / render choose the initial value whenever a property is left unspecified after analysis.
Anonymous
Whoa, the last two lines became large by accident. And I can't seem to edit the description now.
We just now realized that there are other cases that we hadn't considered before making the suggestions. We later imagined about 32+ combinations involving:
* short form v/s long form properties
* declarations within same rule v/s separate rules
* invalid v/s missing properties in a short form property
We were also looking at the behavior of popular browsers and trying to reconcile with our understanding of the specs.
We couldn't reach a definite understanding so far. Frankly, it was a little above our heads. Will update here if we manage to grok it.
best,
hrj
Normally, declarations containing errors (like the background:"red" one) should be completely ignored. In this case, the background variator was not checking the background-position for errors so anything was accepted as background-position and the default color was then used for background-color. Hopefuly fixed by this commit.
Thanks for the fix Radek, verified the fix and works as expected.
Closed in 1.19