On 2010-04-24, at 03:23, Max Carlson wrote:

> Not approved.  I had to change the attribute value comparisons to coerce to 
> strings, since the parsed css attribute values come though that way at line 
> 524:
> 
>         // Check if the rule is currently applicable
>          if ((! rpa) || (node[rpa] + '' == rp.attrvalue)) {

Ah, I see, because your test is looking at a boolean attribute and JS is 
coercing your comparison to a boolean.  Coercing the value to a string is not 
100% accurate though.  I have a little concern about that.  I think the 
accurate choices are:

1) Disallow CSS selectors on non-string attributes (since CSS attribute 
selection is defined to be a string compare).

2) Use presentation types to convert non-string attributes to their string 
representation when comparing (still a little sloppy).

3) Use presentation types to convert the CSS value to the appropriate type when 
comparing.

I think 3) is the most accurate, for `=` comparisons.  It effectively is saying 
"if I used acceptAttribute to set this attribute from this string, would it 
have that value".  If we add `~=` and `|=` comparisons, we would have to use 2) 
for them.  3) could also presumably be cached in the rule, although the type of 
the attr does not have to be a constant -- consider that you could have a 
compound rule on nested views that have the same attribute but where the 
attribute is a different type in the views.  Bleah!

> 
> and line 341:
> 
>            // Only add the rule to the cache if it is _currently_ applicable
>            if (node[rpa] + '' == rp.attrvalue) {
> 
> 
> That got the original testcase listening for mouse events, but swf10 refuses 
> to work except in debug mode.  In the version I sent you I had to change all 
> 'foo in bar' tests to 'bar[foo] != null' - I'm not sure not sure why.

I'll dig in to that.  It is surely the standard swf10 thing where some class is 
sealed so you can't ask `in` about it's properties.  We need to solve that 
issue, because there is a general need to be able to ask that about LZX 
classes.  I'm thinking that since we want the general ability to know the 
declared type of LZX attributes, it's time to bite the bullet and just add such 
a data structure to our classes.  Then we can use that data structure to decide 
if a class has a particular attribute.

Also, I just realized that this change is taking away a huge optimization for 
webtop, which has hundreds of [name=foo] rules.  Since `name` is a constant, we 
need to optimize that.


Reply via email to