Skip to content

Correctly handle empty @content blocks in a @mixin #106

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/transform-content-atrule.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default function transformContentAtrule(rule, opts) {
// transform the clone children
return transformNode(clone, opts).then(() => {
// replace the @content at-rule with the clone children
rule.parent.insertBefore(rule, clone.nodes);
if (clone.nodes) {
rule.parent.insertBefore(rule, clone.nodes);
}

rule.remove();
})
Expand Down
9 changes: 9 additions & 0 deletions test/mixins.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@ $default-radius: 2em;
min-width: $min-width;
}
}

.test-5c {
@include mixin-test-5(50em) {
}
}

.test-5d {
@include mixin-test-5(20em);
}
10 changes: 10 additions & 0 deletions test/mixins.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,13 @@
min-width: 60em;
}
}

.test-5c {
@media (min-width: 50em) {
}
}

.test-5d {
@media (min-width: 20em) {
}
}