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

Add specs for at-rules in nested imports #1429

Merged
merged 2 commits into from
Jul 12, 2019
Merged
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
125 changes: 125 additions & 0 deletions spec/directives/import/nested.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<===> scope/function/input.scss
.parent {
// This should be visible to the imported stylesheet. There's not really a
// good reason for this, but it's the historical behavior so whatever.
@function local() {
@return value;
}

@import 'other';
}

<===> scope/function/other.scss
x {
function: local();
}

<===> scope/function/output.css
.parent x {
function: value;
}

<===>
================================================================================
<===> scope/mixin/input.scss
.parent {
// This should be visible to the imported stylesheet. There's not really a
// good reason for this, but it's the historical behavior so whatever.
@mixin local {
x {y: z}
}

@import 'other';
}

<===> scope/mixin/other.scss
@include local;

<===> scope/mixin/output.css
.parent x {
y: z;
}

<===>
================================================================================
<===> scope/variable/input.scss
.parent {
// This should be visible to the imported stylesheet. There's not really a
// good reason for this, but it's the historical behavior so whatever.
$var: value;
@import 'other';
}

<===> scope/variable/other.scss
x {
var: $var;
}

<===> scope/variable/output.css
.parent x {
var: value;
}

<===>
================================================================================
<===> at_rule/keyframes/input.scss
a {@import "other"}

<===> at_rule/keyframes/_other.scss
// This should ignore the parent selector, since Sass knows @keyframes is only
// valid at the root of a document.
@keyframes b {
0% {c: d}
}

<===> at_rule/keyframes/output.css
@keyframes b {
0% {
c: d;
}
}

<===>
================================================================================
<===> at_rule/childless/input.scss
a {@import "other"}

<===> at_rule/childless/_other.scss
@b c;

<===> at_rule/childless/output.css
a {
@b c;
}

<===>
================================================================================
<===> at_rule/declaration_child/input.scss
a {@import "other"}

<===> at_rule/declaration_child/_other.scss
@b {c: d}

<===> at_rule/declaration_child/output.css
@b {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the expectation here but just want to confirm that the @b should be moved to top level here but not when it is childless?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. An at-rule with children is assumed to behave similar to @media/@supports et al where browsers expect it to appear at the root and contain style rules.

a {
c: d;
}
}

<===>
================================================================================
<===> at_rule/rule_child/input.scss
a {@import "other"}

<===> at_rule/rule_child/_other.scss
@b {
c {d: e}
}

<===> at_rule/rule_child/output.css
@b {
a c {
d: e;
}
}
20 changes: 0 additions & 20 deletions spec/directives/import/nested/function_scope.hrx

This file was deleted.

18 changes: 0 additions & 18 deletions spec/directives/import/nested/mixin_scope.hrx

This file was deleted.

17 changes: 0 additions & 17 deletions spec/directives/import/nested/variable_scope.hrx

This file was deleted.