Skip to content

spaces on selectors (or containers in general) don't work #172

Open

Description

@jquense
parser
  .pseudo({
    value: ':not',
    nodes: [
      selectorParser.selector({
        nodes: [selectorParser.tag({ value: 'span' })],
        spaces: { before: ' ', after: ' ' },
      }),
      selectorParser.selector({
        nodes: [selectorParser.tag({ value: 'span' })],
        spaces: { before: ' ', after: ' ' },
      }),
    ],
  })
  .toString() // ':not(span,span)'

I think the idea is that the spaces go on the nodes, but that's a bit unwieldy of an API when walking through the or transforming selectors, since you drill down and find the first non-container thing to apply spacing too.

Activity

  1. alexander-akait commented on Feb 19, 2019

    @alexander-akait
    Collaborator

    @jquense thanks for issue, why don't use rawSpaceBefore and rawSpaceAfter?

  2. jquense commented on Feb 19, 2019

    @jquense
    Author

    i don't know how too! :) I didn't see that in the documentation. The problem I'm running into here is the case where we replace a pseudo selector with it's children.

    its a bit awkward to do: psuedo.first.first.spaces = psuedo.spaces

  3. alexander-akait commented on Feb 19, 2019

    @alexander-akait
    Collaborator

    @jquense hm, rawSpaceBefore and rawSpaceAfter don't work or it is inconvenient?

  4. jquense commented on Feb 19, 2019

    @jquense
    Author

    they may work, i just don't know what they are. looking at the code tho, toString() for containers doesn't use them?

  5. alexander-akait commented on Feb 19, 2019

    @alexander-akait
    Collaborator
  6. jquense commented on Feb 19, 2019

    @jquense
    Author

    gotcha, yeah that works for a node but selectors are containers and they don't call super() on toString() https://github.com/postcss/postcss-selector-parser/blob/master/src/selectors/container.js#L317

    This may be intentional, it's hard to know if you what to do if you put spaces on both the first node and the selector itself. Overall its more inconvenient than anything, and makes the case where the inner node doesn't exist yet hard

  7. alexander-akait commented on Feb 19, 2019

    @alexander-akait
    Collaborator

    @jquense do you have ideas how we can improve this? You can send a PR and we can discussion in a PR

  8. alexander-akait commented on Feb 25, 2019

    @alexander-akait
    Collaborator

    /cc @jquense friendly ping

  9. jquense commented on Feb 26, 2019

    @jquense
    Author

    I don't have a good suggestion right now unfortunately. I'd be nicer if the logic in postcss-local-by-default could be simplified but i'm not sure the right way to handle it given the way this package works

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