Skip to content

Commit

Permalink
Add deprecation warning for #626.
Browse files Browse the repository at this point in the history
This paves the way to allow us to implement a new syntax for including a
mixin where the mixin being included is specified by a script
expression.
  • Loading branch information
chriseppstein committed Dec 11, 2015
1 parent d1f43c4 commit 7543c98
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
9 changes: 9 additions & 0 deletions lib/sass/tree/visitors/perform.rb
Expand Up @@ -336,6 +336,15 @@ def visit_import(node)
# Loads a mixin into the environment.
def visit_mixindef(node)
env = Sass::Environment.new(@environment, node.options)

if node.name == "mixin"
Sass::Util.sass_warn <<WARNING
DEPRECATION WARNING on line #{node.line}#{" of #{node.filename}" if node.filename}:
Naming a mixin "mixin" is disallowed and will be an error in future versions of Sass.
This conflicts with a new syntax for including mixins when the mixin name is specified dynamically.
WARNING
end

@environment.set_local_mixin(node.name,
Sass::Callable.new(node.name, node.args, node.splat, env,
node.children, node.has_content, "mixin"))
Expand Down
18 changes: 14 additions & 4 deletions test/sass/scss/scss_test.rb
Expand Up @@ -1014,6 +1014,16 @@ def test_function_args
SASS
end

def test_disallowed_mixin_names
assert_warning(<<WARNING) {render(<<SCSS)}
DEPRECATION WARNING on line 1 of test_disallowed_mixin_names_inline.scss:
Naming a mixin "mixin" is disallowed and will be an error in future versions of Sass.
This conflicts with a new syntax for including mixins when the mixin name is specified dynamically.
WARNING
@mixin mixin() {}
SCSS
end

def test_disallowed_function_names
assert_warning(<<WARNING) {render(<<SCSS)}
DEPRECATION WARNING on line 1 of test_disallowed_function_names_inline.scss:
Expand Down Expand Up @@ -3168,12 +3178,12 @@ def test_selector_script_through_mixin
.foo {
content: ".foo"; }
CSS
@mixin mixin {
@mixin a-mixin {
content: "\#{&}";
}
.foo {
@include mixin;
@include a-mixin;
}
SCSS
end
Expand All @@ -3183,12 +3193,12 @@ def test_selector_script_through_content
.foo {
content: ".foo"; }
CSS
@mixin mixin {
@mixin a_mixin {
@content;
}
.foo {
@include mixin {
@include a_mixin {
content: "\#{&}";
}
}
Expand Down

0 comments on commit 7543c98

Please sign in to comment.