Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postcss/postcss-nested
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6.0.1
Choose a base ref
...
head repository: postcss/postcss-nested
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6.2.0
Choose a head ref
  • 12 commits
  • 10 files changed
  • 2 contributors

Commits on Feb 19, 2023

  1. Fix Changelog

    ai committed Feb 19, 2023
    Copy the full SHA
    820eae9 View commit details

Commits on Mar 26, 2023

  1. Add funding option

    ai committed Mar 26, 2023
    Copy the full SHA
    658b1f9 View commit details
  2. Update dependencies

    ai committed Mar 26, 2023
    Copy the full SHA
    01ef893 View commit details

Commits on Oct 7, 2023

  1. Bump postcss from 8.4.21 to 8.4.31 (#158)

    Bumps [postcss](https://github.com/postcss/postcss) from 8.4.21 to 8.4.31.
    - [Release notes](https://github.com/postcss/postcss/releases)
    - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
    - [Commits](postcss/postcss@8.4.21...8.4.31)
    
    ---
    updated-dependencies:
    - dependency-name: postcss
      dependency-type: direct:development
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Oct 7, 2023
    Copy the full SHA
    8eaab00 View commit details
  2. Update dependencies and practies

    ai committed Oct 7, 2023
    Copy the full SHA
    3aa595b View commit details

Commits on Jul 18, 2024

  1. Bump braces from 3.0.2 to 3.0.3 (#160)

    Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
    - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
    - [Commits](micromatch/braces@3.0.2...3.0.3)
    
    ---
    updated-dependencies:
    - dependency-name: braces
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jul 18, 2024
    Copy the full SHA
    98b240f View commit details

Commits on Jul 19, 2024

  1. Update pnpm and Node.js on CI

    ai committed Jul 19, 2024
    Copy the full SHA
    653ea3f View commit details
  2. Move Node.js 16 to old pnpm

    ai committed Jul 19, 2024
    Copy the full SHA
    76593a6 View commit details
  3. Update dependencies

    ai committed Jul 19, 2024
    Copy the full SHA
    80467c5 View commit details
  4. Add starting-style to bubble defaults

    ai committed Jul 19, 2024
    Copy the full SHA
    173cd9a View commit details
  5. Release 6.2 version

    ai committed Jul 19, 2024
    Copy the full SHA
    46b9aae View commit details
  6. Add Github Release support

    ai committed Jul 19, 2024
    Copy the full SHA
    2abd928 View commit details
Showing with 2,240 additions and 1,291 deletions.
  1. +1 −0 .github/FUNDING.yml
  2. +44 −0 .github/workflows/release.yml
  3. +24 −20 .github/workflows/test.yml
  4. +4 −1 CHANGELOG.md
  5. +47 −44 README.md
  6. +3 −0 eslint.config.mjs
  7. +18 −18 index.js
  8. +4 −4 index.test.js
  9. +27 −17 package.json
  10. +2,068 −1,187 pnpm-lock.yaml
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
open_collective: postcss
github: ai
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release
on:
push:
tags:
- '*'
permissions:
contents: write
jobs:
release:
name: Release On Tag
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Extract the changelog
id: changelog
run: |
TAG_NAME=${GITHUB_REF/refs\/tags\//}
READ_SECTION=false
CHANGELOG=""
while IFS= read -r line; do
if [[ "$line" =~ ^#+\ +(.*) ]]; then
if [[ "${BASH_REMATCH[1]}" == "$TAG_NAME" ]]; then
READ_SECTION=true
elif [[ "$READ_SECTION" == true ]]; then
break
fi
elif [[ "$READ_SECTION" == true ]]; then
CHANGELOG+="$line"$'\n'
fi
done < "CHANGELOG.md"
CHANGELOG=$(echo "$CHANGELOG" | awk '/./ {$1=$1;print}')
echo "changelog_content<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create the release
if: steps.changelog.outputs.changelog_content != ''
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
body: '${{ steps.changelog.outputs.changelog_content }}'
draft: false
prerelease: false
44 changes: 24 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -12,63 +12,67 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: latest
version: 9
- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 19
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
run: pnpm install --ignore-scripts
- name: Run tests
run: pnpm test
short:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 20
- 18
- 16
- 14
name: Node.js ${{ matrix.node-version }} Quick
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: latest
version: 9
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
run: pnpm install --ignore-scripts
- name: Run unit tests
run: pnpm unit
old:
runs-on: ubuntu-latest
name: Node.js 12 Quick
strategy:
matrix:
node-version:
- 16
- 14
- 12
name: Node.js ${{ matrix.node-version }} Quick
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 6
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Install Node.js 12
uses: actions/setup-node@v3
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: 12
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
run: pnpm install --no-frozen-lockfile --ignore-scripts
- name: Run unit tests
run: pnpm unit

5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

## 6.1
## 6.2.0
* Added `@starting-style` to bubbling at-rules.

## 6.1.0
* Added `@container` to bubbling at-rules.

## 6.0
91 changes: 47 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,25 +8,25 @@

```css
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
img {
display: block;
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}

.title {
font-size: var(--font);

@at-root html {
--font: 16px
--font: 16px;
}
}
```
@@ -35,39 +35,39 @@ will be processed to:

```css
.phone_title {
width: 500px;
width: 500px;
}
@media (max-width: 500px) {
.phone_title {
width: auto;
}
.phone_title {
width: auto;
}
}
body.is_dark .phone_title {
color: white;
color: white;
}
.phone img {
display: block;
display: block;
}

.title {
font-size: var(--font);
}
html {
--font: 16px
--font: 16px;
}
```

Related plugins:

* Use [`postcss-current-selector`] **after** this plugin if you want
- Use [`postcss-current-selector`] **after** this plugin if you want
to use current selector in properties or variables values.
* Use [`postcss-nested-ancestors`] **before** this plugin if you want
- Use [`postcss-nested-ancestors`] **before** this plugin if you want
to reference any ancestor element directly in your selectors with `^&`.

Alternatives:

* See also [`postcss-nesting`], which implements [CSSWG draft].
* [`postcss-nested-props`] for nested properties like `font-size`.
- See also [`postcss-nesting`], which implements [CSSWG draft].
- [`postcss-nested-props`] for nested properties like `font-size`.

<a href="https://evilmartians.com/?utm_source=postcss-nested">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
@@ -76,11 +76,10 @@ Alternatives:

[`postcss-current-selector`]: https://github.com/komlev/postcss-current-selector
[`postcss-nested-ancestors`]: https://github.com/toomuchdesign/postcss-nested-ancestors
[`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props
[`postcss-nesting`]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/
[PostCSS]: https://github.com/postcss/postcss

[`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props
[`postcss-nesting`]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/
[PostCSS]: https://github.com/postcss/postcss

## Usage

@@ -110,16 +109,16 @@ module.exports = {

[official docs]: https://github.com/postcss/postcss#usage


## Options

### `bubble`

By default, plugin will bubble only `@media`, `@supports` and `@layer`
at-rules. Use this option to add your custom at-rules to this list.
By default, plugin will bubble only `@media`, `@supports`, `@layer`,
`@container`, and `@starting-style` at-rules. Use this option
to add your custom at-rules to this list.

```js
postcss([ require('postcss-nested')({ bubble: ['phone'] }) ])
postcss([require('postcss-nested')({ bubble: ['phone'] })])
```

```css
@@ -141,14 +140,13 @@ a {
}
```


### `unwrap`

By default, plugin will unwrap only `@font-face`, `@keyframes` and `@document`
at-rules. You can add your custom at-rules to this list by `unwrap` option:

```js
postcss([ require('postcss-nested')({ unwrap: ['phone'] }) ])
postcss([require('postcss-nested')({ unwrap: ['phone'] })])
```

```css
@@ -168,51 +166,56 @@ a {
}
```


### `preserveEmpty`

By default, plugin will strip out any empty selector generated by intermediate
nesting levels. You can set `preserveEmpty` to `true` to preserve them.

```css
.a {
.b {
color: black;
}
.b {
color: black;
}
}
```

Will be compiled to:

```css
.a { }
.a {
}
.a .b {
color: black;
color: black;
}
```

This is especially useful if you want to export the empty classes with `postcss-modules`.


### `rootRuleName`

The plugin supports the SCSS custom at-rule `@at-root` which breaks rule
blocks out of their nested position. If you want, you can choose a new
custom name for this rule in your code.

```js
postcss([ require('postcss-nested')({ rootRuleName: '_escape-nesting' }) ])
postcss([require('postcss-nested')({ rootRuleName: '_escape-nesting' })])
```

```css
/* input */
.a {
color: white;
@_escape-nesting {
.b { color: black; }
.b {
color: black;
}
}
}
/* output */
.a { color: white; }
.b { color: black; }
.a {
color: white;
}
.b {
color: black;
}
```
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import loguxConfig from '@logux/eslint-config'

export default [...loguxConfig]
Loading