Re: [css3-fonts][cssom] proposal for revised definition of CSSFontFaceRule

On Sat, Sep 22, 2012 at 6:35 AM, Sebastian Zartner <
sebastianzartner@gmail.com> wrote:

>  > Ok. As long as there will be a mapping between them it's fine for me.
>>
>> Yeah, the mapping is trivial:
>>
>> function camelCaseFromDashes(str) {
>>         str = str.toLowerCase();
>>         var ret = '';
>>         for(var i = 0; i < str.length; i++) {
>>                 if(str[i] == '-' && i+1 < str.length) {
>>                         ret += str[i+1].toUpperCase();
>>                         i++;
>>                 } else {
>>                         ret += str[i];
>>                 }
>>         }
>>         return ret;
>> }
>>
>> function dashesFromCamelCase(str) {
>>         var ret = '';
>>         for(var i = 0; i < str.length; i++) {
>>                 if(str[i].match(/[A-Z]/)) {
>>                         ret += '-' + str[i].toLowerCase();
>>                 } else {
>>                         ret += str[i];
>>                 }
>>         }
>>         return ret;
>> }
>
>
> This can even be reached easier:
>
> function camelCaseFromDashes(str) {
>   return str.replace(/-./g, function(m) { return m[1].toUpperCase(); });
> }
>
> function dashesFromCamelCase(str) {
>   str.replace(/[A-Z]/g, function(m) { return "-"+m[0].toLowerCase(); });
> }
>
> Though I was not talking of a JavaScript mapping. I was talking of a
> mapping in CSSOM as Glenn mentioned it. Imagine the camelCase notation
> differs from the property name notation for some reason.
>

We also need an exclusions (special cases) list, e.g., 'float' ->
'cssFloat' [if this mapping is to be defined in the spec as potentially
useful for styles as well as descriptors].

I'll take a stab at defining the mapping in a new ED update later today.

Received on Friday, 21 September 2012 23:17:31 UTC