beautifier / js-beautify

Beautifier for javascript
https://beautifier.io
MIT License
8.62k stars 1.39k forks source link

Adjacent and direct descendant selectors are not space separated #676

Open raduluchian opened 9 years ago

raduluchian commented 9 years ago

Altought the CSS rule for "selector_separator" is set to " " (space character) this doesn't apply to rules that use direct descendant selectors or adjacent selectors. For example the following code...

a+b {
    ...
}

a>b {
    ...
}

... doesn't get formatted into this:

a + b {
     ...
}

a > b {
    ...
}
bitwiseman commented 9 years ago

So, the space shouldn't be added, but is?

raduluchian commented 9 years ago

Nope, quite the opposite: the space should be added but isn't.

bitwiseman commented 9 years ago

Oh, okay. :smile: What would you expect to see if "selector_separator" were set to "\n"?

raduluchian commented 9 years ago

I suppose to see each selector on a separate line, even if they are part of the same rule. So I would expect this code:

.one .two .three {
    ...
}

to be formatted into this:

.one
.two
.three {
    ...
}
bitwiseman commented 9 years ago

What about your original example?

raduluchian commented 9 years ago
a>b {
    ...
}

would turn into this:

a
>
b {
    ...
}
raduluchian commented 8 years ago

This issue had it's one year birthday yesterday. :) Any updates on it?

bitwiseman commented 8 years ago

Nope. This project is widely used and I devote what time I can to it, but it needs more contributors.

bitwiseman commented 8 years ago

@raduluchian - Have you tried setting space_around_selector_separator = true? The name is odd, but I think that will do what you want.

smonff commented 7 years ago

@bitwiseman The space_around_selector_separator parameter set to true fix this issue.

Though, it should be like that by default: I cannot think of a situation where you wouldn't want js-beautify-css not to add (or maintain existing spaces) between + or > relationship separators because it breaks your CSS rules (I mean, it is not an "aesthetic" bug).

FrEaKmAn commented 4 years ago

For anyone wondering, this has been update to space_around_combinator

dosicker commented 2 months ago

For anyone wondering, this has been update to space_around_combinator

Woo woo woo ~ tks tks tks very!

dosicker commented 2 months ago

For anyone wondering, this has been update to space_around_combinator

Sob~ this property configuration still doesn't work... Then I found this related update adjustment Implement option to support adding spaces between CSS selectors

dosicker commented 2 months ago

For anyone wondering, this has been update to space_around_combinator

Sob~ this property configuration still doesn't work... Then I found this related update adjustment Implement option to support adding spaces between CSS selectors

After a walk, I came back and found that this attribute is effective. I found that my writing was wrong.

It was written like this before: wrong

But in fact the correct configuration is: correct

~🤡🤡🤡~

:)

bitwiseman commented 1 month ago

@dosicker Could you open a new issue for this. I think it would make sense if one of the beautifier modules sees a JSON element matching itself it should drill into that.
The fact that they don't is not an outright bug, but it's behavior that could be improved.

dosicker commented 1 month ago

@dosicker Could you open a new issue for this. I think it would make sense if one of the beautifier modules sees a JSON element matching itself it should drill into that. The fact that they don't is not an outright bug, but it's behavior that could be improved.

Thanks you reply! and...Yeah, maybe you misunderstood me. My statement above was to say that I was stupid... which led to the wrong use of the property...

But what you meant by this sentence is that the configuration of this property should actually be written in the CSS object, not in the top-level configuration, that right?

bitwiseman commented 1 month ago

@dosicker It's okay that it works in the root object, that is reasonable behavior. It is a bug that it doesn't work when inside the css object.

dosicker commented 1 month ago

@dosicker It's okay that it works in the root object, that is reasonable behavior. It is a bug that it doesn't work when inside the css object.

yeah, ok~ got it. I'll take time to create a new issue.