Re: [css3-values] Suggestion: Allowing attr() in calc()

> On 9/1/10 2:41 PM, Boris Zbarsky wrote:
>> On 9/1/10 2:39 PM, Lea Verou wrote:
>>>
>>>> I must be missing something here. Say I have this rule:
>>>>
>>>> * { width: calc(attr(border) * 10px); }
>>>>
>>>> and this HTML document:
>>>>
>>>> <table border=1"></table>
>>>> <div border="1"></div>
>>>>
>>>> What are the computed widths of the div and table, and why?
>>>>
>>>> -Boris
>>> Same as:
>>> * { width: calc(1 * 10px); }
>>>
>>> Which if my understanding is correct ends up being equivalent to:
>>> * { width: 10px; }
>>>
>>> Am I missing something?
>>
>> The "width" attribute on <div> is not an integer attribute. It's just a
>> string attribute.
>
> Er, of course I meant the "border" attribute.  But the point is that the type of an attribute depends on the node.
>
> -Boris
Oh, right. As things currently stand, I guess it should be a parse error then (in the 2nd case), unless a type is explicitly specified.
However, if this is actually implemented:
>
> If the <type> is missing, ‘|string| <http://dev.w3.org/csswg/css3-values/#string>’ is implied.
>
> Ideally, it shouldn't be necessary to specify the type if it is obvious. For example, this should be valid: "background-image: attr(href);". This could be described as: "If the property only accepts one type of value (aside from ‘|inherit|’ and ‘|initial|’), that type is implied".
>
(from http://dev.w3.org/csswg/css3-values/#the-calc-min-and-max-functions)
it could be assumed to be a number, when used in calc() expressions without a type.

-- 
Lea Verou
Blog: leaverou.me <http://leaverou.me>
Twitter: http://twitter.com/LeaVerou
LinkedIn: http://gr.linkedin.com/in/leaverou

Received on Wednesday, 1 September 2010 19:20:39 UTC