Skip to content

Doesn't parse number sign character #6

Description

@radarfox

From the CSS specification:

The format of a length value is an optional sign character ('+' or '-', with '+' being the default) immediately followed by a number...

Current output:

  • -1px => [{"type":"ident","string":"-1px"}]
  • -1 => [{"type":"ident","string":"-1"}]
  • -0 => [{"type":"ident","string":"-0"}]
  • +0 => throws failed to parse near +0...
  • +1 => throws failed to parse near +1...
  • +1px => throws failed to parse near +1px...

Expected output:

  • -1px => { type: 'number', string: '-1px', unit: 'px', value: -1 }
  • -1 => { type: 'number', string: '-1', unit: '', value: -1 }
  • -0 => { type: 'number', string: '-0', unit: '', value: -0 }
  • +0 => { type: 'number', string: '+0', unit: '', value: 0 }
  • +1 => { type: 'number', string: '+1', unit: '', value: 1 }
  • +1px => { type: 'number', string: '+1px', unit: 'px', value: 1 }

Activity

  1. tj commented on Jun 24, 2019

    @tj
    Member

    Post CSS is more or less the same as Rework (but actively maintained), you might be better off using that these days

  2. radarfox commented on Jun 26, 2019

    @radarfox
    Author

    Thanks for the response, but it seem to me, that Rework doesn't parse the values. All I need is to convert "-1px" into {value: -1, unit: "px"}.

    In Rework i need to do something like * {top: -12px} and all I get is {property: "top", type: "declaration", value: "-12px"} which i useless to me.

    Or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions