This is expected behavior. The reason for it is not that edgar is looking
at its parent for the value of testdata, it's that edgar is also a view,
and right now our specificity stuff doesn't account for the more direct
applicability of the subclass selector.

You can confirm this by switching the order of the rules, and you'll get a
different result. I assume that the applicability of rules with the same
specificity in CSS is undefined, but ours happen to roughly mimic lexical
order for now because we are using array.sort which I think is stable.

It would be nice to make subclasses more specific than superclasses, but
that would make specificity a function of not only the selector, but also
the node being selected, and that seems like a pain.

A

On Sep 8, Benjamin Shine wrote:

> LPP-2618, combined with an example from Gregor, started an inquiry, which led
> me to something weird.
> 
> Take these three rules:
> 
>        /* rule 1, specificity 10 */
>        [name="thename"] {
>            testdata: "i am thename";
>        }
> 
>        /* rule 2, specificity 1 */
>        testclass {
>            testdata: "i am testclass";
>        }
> 
>        /* rule 3, specificity 1 */
>        view {
>            testdata: "i am view";
>        }
> 
> And this view structure:
> 
>        <view name="thename">
>            <testclass id="edgar">
>                <attribute name="testdata" value="$style{'testdata'}" />
>            </testclass>
>        </view>
> 
> 
> What should the value of edgar.testdata be?
> Intuitively, I want edgar.testdata to be "i am testclass". What *edgar* is
> should matter more than one of edgar's ancestors' attributes.
> That's not what happens.
> edgar.getAttribute("testdata") returns "i am view"
> 
> All the nearby screw cases I can think of seem to be handled the way I expect
> them to be, but inconsistently with the edgar case.
> 
> I'm attaching a tar with the test cases, and a couple other test cases I've
> been working on. Adam and Gregor -- what do you think? Am I perseverating
> here, or is this really a sign of a problem that we care about?
> 
> This test is in
> http://localhost:8080/trunk-csswork/test/style/attrselector/main.lzx
> 
> 
_______________________________________________
Laszlo-dev mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-dev

Reply via email to