W3C home > Mailing lists > Public > www-style@w3.org > September 2012

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

From: Glenn Adams <glenn@skynav.com>
Date: Sat, 22 Sep 2012 07:16:44 +0800
Message-ID: <CACQ=j+dTxRhHvyZk1JCzF+6aXBg46V87y=Q5X-w7XOHbD9EEPA@mail.gmail.com>
To: Sebastian Zartner <sebastianzartner@gmail.com>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Boris Zbarsky <bzbarsky@mit.edu>, John Daggett <jdaggett@mozilla.com>, www-style list <www-style@w3.org>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:00 GMT