Loading ...
Sorry, an error occurred while loading the content.

`rgba` is unrecognized

Expand Messages
  • Mike West
    JSLint doesn t appear to recognize the (relatively new) `rgba` syntax for defining colors with alpha channels. Specifically: @charset UTF-8 ; div {
    Message 1 of 3 , Jan 19, 2010
    • 0 Attachment
      JSLint doesn't appear to recognize the (relatively new) `rgba` syntax
      for defining colors with alpha channels. Specifically:

      @charset "UTF-8";

      div {
      background: rgb( 0, 0, 0 );
      background: rgba( 0, 0, 0, 0.5 );
      }

      gives the following errors:

      Error:
      Problem at line 5 character 21: Unexpected token 'rgba'.

      background: rgba( 0, 0, 0, 0.5 );

      Problem at line 5 character 25: Expected ';' and instead saw '('.

      background: rgba( 0, 0, 0, 0.5 );

      Problem at line 5 character 27: Excepted a style attribute, and
      instead saw '0'.

      background: rgba( 0, 0, 0, 0.5 );

      Problem at line 5 character 28: Expected ':' and instead saw ','.

      background: rgba( 0, 0, 0, 0.5 );

      Problem at line 301 character 30: Result of expression 'v'
      [undefined] is not an object.

      Adjusting the `cssColor` function to look for `rgb` and `rgba`, and
      setting the number of expected tokens accordingly, looks like it
      addresses the issue. I've done this here as an example:
      http://gist.github.com/281085

      Thanks!

      -Mike
    • Douglas Crockford
      ... Thanks. Please try it now.
      Message 2 of 3 , Jan 19, 2010
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, Mike West <mike@...> wrote:
        >
        > JSLint doesn't appear to recognize the (relatively new) `rgba` syntax
        > for defining colors with alpha channels. Specifically:
        >
        > @charset "UTF-8";
        >
        > div {
        > background: rgb( 0, 0, 0 );
        > background: rgba( 0, 0, 0, 0.5 );
        > }
        >
        > gives the following errors:
        >
        > Error:
        > Problem at line 5 character 21: Unexpected token 'rgba'.

        Thanks. Please try it now.
      • Mike West
        On Tue, Jan 19, 2010 at 6:31 PM, Douglas Crockford ... Wow, quick turnaround! Works wonderfully. In the meantime, I ve made another mistake regarding RGBA
        Message 3 of 3 , Jan 19, 2010
        • 0 Attachment
          On Tue, Jan 19, 2010 at 6:31 PM, Douglas Crockford
          <douglas@...> wrote:

          >> JSLint doesn't appear to recognize the (relatively new) `rgba` syntax
          >> for defining colors with alpha channels.  Specifically:
          >
          > Thanks. Please try it now.


          Wow, quick turnaround! Works wonderfully. In the meantime, I've made
          another mistake regarding RGBA that JSLint might catch: the last
          parameter must be a decimal between 0 and 1, but it's easy to forget
          and try to use a percentage...

          I've updated http://gist.github.com/281085 to show a possible way to
          approach throwing warnings for this parameter. Using the following
          test data, it seems to work well, throwing warnings for the last two
          rules:

          @charset "UTF-8";

          div {
          background: rgb( 0, 0, 0 );
          background: rgba( 0, 0, 0, 0.5 );
          background: rgba( 0, 0, 0, 255 );
          background: rgba( 0, 0, 0, 0.5% );
          }

          Thanks!

          -Mike
        Your message has been successfully submitted and would be delivered to recipients shortly.