Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested CSS adds extra & characters (that are not necessary?) #862

Open
KeesCBakker opened this issue Dec 2, 2024 · 1 comment
Open

Nested CSS adds extra & characters (that are not necessary?) #862

KeesCBakker opened this issue Dec 2, 2024 · 1 comment

Comments

@KeesCBakker
Copy link

KeesCBakker commented Dec 2, 2024

It looks like nested css adds extra & characters, which are not needed. I'm using NPM version 1.28.2 of the lightningcss package.

const { transform } = require("lightningcss");

let css = `
.outer {
  color: red;
  .inner {
    color: blue;
  }
  .another-inner {
    color: black;
  }
}`;

let { code } = transform({
  code: Buffer.from(css),
  minify: true,
  sourceMap: false
});

console.log(code.toString());

This outputs:

.outer{color:red;& .inner{color:#00f}& .another-inner{color:#000}}

When I prettify it, we'll get:

.outer {
	color: red;

	& .inner {
		color: #00f
	}

	& .another-inner {
		color: #000
	}
}

Why are the &-characters added? I think they might not be needed.

@KeesCBakker KeesCBakker changed the title Nested CSS adds extra & characters Nested CSS adds extra & characters (that are not necessary?) Dec 2, 2024
@fregante
Copy link

fregante commented Dec 9, 2024

It used to be required, refer to "Partial support" notes on https://issues.chromium.org/40261706 or the specific Chromium issue https://issues.chromium.org/issues/40261706

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants