Skip to content

Commit

Permalink
Drop support for the reference combinator. (#2317)
Browse files Browse the repository at this point in the history
Closes #303
  • Loading branch information
nex3 committed Jun 16, 2017
1 parent 976cfa6 commit e97ba4c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 73 deletions.
26 changes: 14 additions & 12 deletions doc-src/SASS_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@

### Backwards Incompatibilities -- Must Read!

Certain ways of using `#{}` without quotes in property and variable values,
which were deprecated in version 3.4.20, have been removed entirely in order to
simplify the feature.
* Certain ways of using `#{}` without quotes in property and variable values,
which were deprecated in version 3.4.20, have been removed entirely in order
to simplify the feature.

Previously, `#{}` behaved unpredictably. If it was used near operators, it would
cause those operators to become part of an unquoted string instead of having
their normal meaning. This wan't an especially useful feature, and it made it
hard to reason about some code that included `#{}`.
Previously, `#{}` behaved unpredictably. If it was used near operators, it
would cause those operators to become part of an unquoted string instead of
having their normal meaning. This wan't an especially useful feature, and it
made it hard to reason about some code that included `#{}`.

Now `#{}` just returns an unquoted string that acts like any other unquoted
string. For example, `foo + #{$var}` does the same thing as `foo + $var`,
instead of doing the same thing as `unquote("foo + #{$var}")`.
Now `#{}` just returns an unquoted string that acts like any other unquoted
string. For example, `foo + #{$var}` does the same thing as `foo + $var`,
instead of doing the same thing as `unquote("foo + #{$var}")`.

For more details, see [this blog post][interp-blog] and
[the GitHub issue in which it was planned][interp-issue].
For more details, see [this blog post][interp-blog] and
[the GitHub issue in which it was planned][interp-issue].

* The reference combinator, `/foo/` is no longer supported.

## 3.5.0

Expand Down
18 changes: 1 addition & 17 deletions lib/sass/scss/static_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,7 @@ def selector
end

def combinator
tok(PLUS) || tok(GREATER) || tok(TILDE) || reference_combinator
end

def reference_combinator
return unless tok(%r{/})
res = '/'
ns, name = expr!(:qualified_name)
res << ns << '|' if ns
res << name << tok!(%r{/})

location = " of #{@filename}" if @filename
Sass::Util.sass_warn <<MESSAGE
DEPRECATION WARNING on line #{@line}, column #{@offset}#{location}:
The reference combinator #{res} is deprecated and will be removed in a future release.
MESSAGE

res
tok(PLUS) || tok(GREATER) || tok(TILDE)
end

def simple_selector_sequence
Expand Down
2 changes: 1 addition & 1 deletion test/sass/engine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2862,7 +2862,7 @@ def test_selector_compression
end

def test_comment_like_selector
assert_raise_message(Sass::SyntaxError, 'Invalid CSS after "/": expected identifier, was " foo"') {render(<<SASS)}
assert_raise_message(Sass::SyntaxError, 'Invalid CSS after "": expected selector, was "/ foo"') {render(<<SASS)}
/ foo
a: b
SASS
Expand Down
6 changes: 0 additions & 6 deletions test/sass/extend_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -644,12 +644,6 @@ def test_nested_extender_doesnt_find_common_selectors_around_sibling_selector
assert_extends 'a ~ b c .c1', 'b c .c2 {@extend .c1}', 'a ~ b c .c1, a ~ b c .c2'
end

def test_nested_extender_doesnt_find_common_selectors_around_reference_selector
silence_warnings {assert_extends 'a /for/ b c .c1', 'a c .c2 {@extend .c1}', 'a /for/ b c .c1, a /for/ b a c .c2, a a /for/ b c .c2'}
silence_warnings {assert_extends 'a /for/ b c .c1', 'a b .c2 {@extend .c1}', 'a /for/ b c .c1, a a /for/ b c .c2'}
silence_warnings {assert_extends 'a /for/ b c .c1', 'b c .c2 {@extend .c1}', 'a /for/ b c .c1, a /for/ b c .c2'}
end

def test_nested_extender_with_early_child_selectors_doesnt_subseq_them
assert_extends('.bip > .bap .foo', '.grip > .bap .bar {@extend .foo}',
'.bip > .bap .foo, .bip > .bap .grip > .bap .bar, .grip > .bap .bip > .bap .bar')
Expand Down
5 changes: 1 addition & 4 deletions test/sass/scss/css_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -805,11 +805,8 @@ def test_summarized_selectors_with_element
assert_selector_parses('E > F')
assert_selector_parses('E + F')
assert_selector_parses('E ~ F')
silence_warnings {assert_selector_parses('E /foo/ F')}
silence_warnings {assert_selector_parses('E! > F')}

silence_warnings {assert_selector_parses('E /ns|foo/ F')}

# From http://dev.w3.org/csswg/css-scoping-1/
assert_selector_parses('E:host(s)')
assert_selector_parses('E:host-context(s)')
Expand Down Expand Up @@ -1167,7 +1164,7 @@ def test_very_long_comment_doesnt_take_forever

def test_long_unclosed_comment_doesnt_take_forever
assert_raise_message(Sass::SyntaxError,
'Invalid CSS after "/*": expected "/", was "//*************..."') {render(<<SCSS)}
'Invalid CSS after "": expected selector or at-rule, was "/*"') {render(<<SCSS)}
/*
//**************************************************************************
SCSS
Expand Down
33 changes: 0 additions & 33 deletions test/sass/scss/scss_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2173,18 +2173,6 @@ def test_selector_interpolation_at_dashes
SCSS
end

def test_selector_interpolation_in_reference_combinator
silence_warnings {assert_equal <<CSS, render(<<SCSS)}
.foo /a/ .bar /b|c/ .baz {
a: b; }
CSS
$a: a;
$b: b;
$c: c;
.foo /\#{$a}/ .bar /\#{$b}|\#{$c}/ .baz {a: b}
SCSS
end

def test_parent_selector_with_parent_and_subject
silence_warnings {assert_equal <<CSS, render(<<SCSS)}
bar foo.baz! .bip {
Expand Down Expand Up @@ -3825,27 +3813,6 @@ def test_import_comments_in_imports
SCSS
end

def test_reference_combinator_with_parent_ref
silence_warnings {assert_equal <<CSS, render(<<SCSS)}
a /foo/ b {
c: d; }
CSS
a {& /foo/ b {c: d}}
SCSS
end

def test_reference_combinator_warning
assert_warning(<<WARNING) {assert_equal <<CSS, render(<<SCSS)}
DEPRECATION WARNING on line 1, column 8 of test_reference_combinator_warning_inline.scss:
The reference combinator /foo/ is deprecated and will be removed in a future release.
WARNING
a /foo/ b {
c: d; }
CSS
a {& /foo/ b {c: d}}
SCSS
end

def test_newline_selector_rendered_multiple_times
assert_equal <<CSS, render(<<SCSS)
form input,
Expand Down

0 comments on commit e97ba4c

Please sign in to comment.