Browse files

Fully disable @extend in @media.

Update #154
  • Loading branch information...
1 parent 319056f commit e9910bf5f2f43bf65e5a54bc18a16511af2a40f9 @nex3 nex3 committed May 12, 2012
View
3 doc-src/SASS_CHANGELOG.md
@@ -134,6 +134,9 @@ that make use of `@media` and other directives dynamically.
are fully disallowed.
They were deprecated in 3.1.8.
+* `@extend` may not be used within directives such as `@media`. This was
+ deprecated in 3.1.18.
+
* `#{}` interpolation is now allowed in all comments.
* The `!` flag may not be used with `//` comments (e.g. `//!`).
View
12 lib/sass/tree/extend_node.rb
@@ -25,17 +25,5 @@ def initialize(selector)
@selector = selector
super()
end
-
- # Disables this `@extend` due to it being inside a directive.
- def disable!
- @disabled = true
- end
-
- # Whether this `@extend` is disabled due to it being inside a directive.
- #
- # @return [Boolean]
- def disabled?
- @disabled
- end
end
end
View
3 lib/sass/tree/media_node.rb
@@ -27,6 +27,9 @@ def initialize(query)
# @see DirectiveNode#value
def value; raise NotImplementedError; end
+ # @see DirectiveNode#name
+ def name; '@media'; end
+
# @see DirectiveNode#resolved_value
def resolved_value
@resolved_value ||= "@media #{query.to_css}"
View
16 lib/sass/tree/visitors/check_nesting.rb
@@ -72,16 +72,12 @@ def invalid_extend_parent?(parent, child)
return "Extend directives may only be used within rules."
end
- if !child.disabled? &&
- directive = @parents.find {|p| p.is_a?(Sass::Tree::DirectiveNode)}
- child.disable!
- Sass::Util.sass_warn <<WARNING
-DEPRECATION WARNING on line #{child.line}#{" of #{child.filename}" if child.filename}:
- Using @extend within directives (e.g. #{directive.name}) is deprecated.
- It will be an error in Sass 3.2.
- This will only work once @extend is supported natively in the browser.
-WARNING
- nil
+ if directive = @parents.find {|p| p.is_a?(Sass::Tree::DirectiveNode)}
+ return <<ERR.rstrip
+@extend may not be used within directives (e.g. #{directive.name}).
+
+This will only work once @extend is supported natively in the browser.
+ERR
end
end
View
1 lib/sass/tree/visitors/cssize.rb
@@ -83,7 +83,6 @@ def visit_root(node)
# Registers an extension in the `@extends` subset map.
def visit_extend(node)
- return [] if node.disabled?
node.resolved_selector.members.each do |seq|
if seq.members.size > 1
raise Sass::SyntaxError.new("Can't extend #{seq.to_a.join}: can't extend nested selectors")
View
2 test/sass/engine_test.rb
@@ -146,6 +146,8 @@ class SassEngineTest < Test::Unit::TestCase
"$var: true\n@while $var\n @extend .bar\n $var: false" => ["Extend directives may only be used within rules.", 3],
"@for $i from 0 to 1\n @extend .bar" => ["Extend directives may only be used within rules.", 2],
"@mixin foo\n @extend .bar\n@include foo" => ["Extend directives may only be used within rules.", 2],
+ "@media screen\n .bar\n @extend .foo" => "@extend may not be used within directives (e.g. @media).\n\nThis will only work once @extend is supported natively in the browser.",
+ "@flooblehoof\n .bar\n @extend .foo" => "@extend may not be used within directives (e.g. @flooblehoof).\n\nThis will only work once @extend is supported natively in the browser.",
"foo\n &a\n b: c" => ["Invalid CSS after \"&\": expected \"{\", was \"a\"\n\n\"a\" may only be used at the beginning of a selector.", 2],
"foo\n &1\n b: c" => ["Invalid CSS after \"&\": expected \"{\", was \"1\"\n\n\"1\" may only be used at the beginning of a selector.", 2],
"foo %\n a: b" => ['Invalid CSS after "foo %": expected placeholder name, was ""', 1],
View
36 test/sass/extend_test.rb
@@ -795,42 +795,6 @@ def test_media_in_placeholder_selector
SCSS
end
- def test_extend_in_media
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SCSS))}
-DEPRECATION WARNING on line 3 of test_extend_in_media_inline.sass:
- Using @extend within directives (e.g. @media) is deprecated.
- It will be an error in Sass 3.2.
- This will only work once @extend is supported natively in the browser.
-WARN
-.foo {
- a: b; }
-CSS
-.foo {a: b}
-@media screen {
- .bar {@extend .foo}
-}
-SCSS
- end
-
- def test_extend_in_unknown_directive
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SCSS))}
-DEPRECATION WARNING on line 3 of test_extend_in_unknown_directive_inline.sass:
- Using @extend within directives (e.g. @flooblehoof) is deprecated.
- It will be an error in Sass 3.2.
- This will only work once @extend is supported natively in the browser.
-WARN
-.foo {
- a: b; }
-
-@flooblehoof {}
-CSS
-.foo {a: b}
-@flooblehoof {
- .bar {@extend .foo}
-}
-SCSS
- end
-
# Regression Tests
def test_newline_near_combinator

0 comments on commit e9910bf

Please sign in to comment.