sass 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +58 -50
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/VERSION_NAME +1 -1
- data/bin/sass +1 -1
- data/bin/scss +1 -1
- data/lib/sass/cache_stores/filesystem.rb +6 -2
- data/lib/sass/css.rb +1 -3
- data/lib/sass/engine.rb +37 -46
- data/lib/sass/environment.rb +13 -17
- data/lib/sass/error.rb +6 -9
- data/lib/sass/exec/base.rb +187 -0
- data/lib/sass/exec/sass_convert.rb +264 -0
- data/lib/sass/exec/sass_scss.rb +424 -0
- data/lib/sass/exec.rb +5 -771
- data/lib/sass/features.rb +7 -0
- data/lib/sass/importers/base.rb +7 -2
- data/lib/sass/importers/filesystem.rb +9 -25
- data/lib/sass/importers.rb +0 -1
- data/lib/sass/media.rb +1 -4
- data/lib/sass/plugin/compiler.rb +200 -83
- data/lib/sass/plugin/staleness_checker.rb +1 -1
- data/lib/sass/plugin.rb +3 -3
- data/lib/sass/script/css_lexer.rb +1 -1
- data/lib/sass/script/functions.rb +622 -268
- data/lib/sass/script/lexer.rb +99 -34
- data/lib/sass/script/parser.rb +24 -23
- data/lib/sass/script/tree/funcall.rb +1 -1
- data/lib/sass/script/tree/interpolation.rb +20 -2
- data/lib/sass/script/tree/selector.rb +26 -0
- data/lib/sass/script/tree/string_interpolation.rb +1 -1
- data/lib/sass/script/tree.rb +1 -0
- data/lib/sass/script/value/base.rb +7 -5
- data/lib/sass/script/value/bool.rb +0 -5
- data/lib/sass/script/value/color.rb +39 -21
- data/lib/sass/script/value/helpers.rb +107 -0
- data/lib/sass/script/value/list.rb +0 -15
- data/lib/sass/script/value/null.rb +0 -5
- data/lib/sass/script/value/number.rb +62 -14
- data/lib/sass/script/value/string.rb +59 -11
- data/lib/sass/script/value.rb +0 -1
- data/lib/sass/scss/css_parser.rb +8 -2
- data/lib/sass/scss/parser.rb +190 -328
- data/lib/sass/scss/rx.rb +15 -6
- data/lib/sass/scss/static_parser.rb +298 -1
- data/lib/sass/selector/abstract_sequence.rb +28 -13
- data/lib/sass/selector/comma_sequence.rb +92 -13
- data/lib/sass/selector/pseudo.rb +256 -0
- data/lib/sass/selector/sequence.rb +94 -24
- data/lib/sass/selector/simple.rb +14 -25
- data/lib/sass/selector/simple_sequence.rb +97 -33
- data/lib/sass/selector.rb +57 -194
- data/lib/sass/shared.rb +1 -1
- data/lib/sass/source/map.rb +26 -12
- data/lib/sass/stack.rb +0 -6
- data/lib/sass/supports.rb +2 -3
- data/lib/sass/tree/at_root_node.rb +1 -0
- data/lib/sass/tree/charset_node.rb +1 -1
- data/lib/sass/tree/directive_node.rb +8 -2
- data/lib/sass/tree/error_node.rb +18 -0
- data/lib/sass/tree/extend_node.rb +1 -1
- data/lib/sass/tree/function_node.rb +4 -0
- data/lib/sass/tree/keyframe_rule_node.rb +15 -0
- data/lib/sass/tree/prop_node.rb +1 -1
- data/lib/sass/tree/rule_node.rb +12 -7
- data/lib/sass/tree/visitors/check_nesting.rb +38 -10
- data/lib/sass/tree/visitors/convert.rb +16 -18
- data/lib/sass/tree/visitors/cssize.rb +29 -29
- data/lib/sass/tree/visitors/deep_copy.rb +5 -0
- data/lib/sass/tree/visitors/perform.rb +45 -33
- data/lib/sass/tree/visitors/set_options.rb +14 -0
- data/lib/sass/tree/visitors/to_css.rb +15 -14
- data/lib/sass/util/subset_map.rb +1 -1
- data/lib/sass/util.rb +222 -99
- data/lib/sass/version.rb +5 -5
- data/lib/sass.rb +0 -5
- data/test/sass/cache_test.rb +62 -20
- data/test/sass/callbacks_test.rb +1 -1
- data/test/sass/compiler_test.rb +19 -10
- data/test/sass/conversion_test.rb +58 -1
- data/test/sass/css2sass_test.rb +23 -4
- data/test/sass/encoding_test.rb +219 -0
- data/test/sass/engine_test.rb +136 -199
- data/test/sass/exec_test.rb +2 -2
- data/test/sass/extend_test.rb +236 -19
- data/test/sass/functions_test.rb +295 -253
- data/test/sass/importer_test.rb +31 -21
- data/test/sass/logger_test.rb +1 -1
- data/test/sass/more_results/more_import.css +1 -1
- data/test/sass/plugin_test.rb +14 -13
- data/test/sass/results/compact.css +1 -1
- data/test/sass/results/complex.css +4 -4
- data/test/sass/results/expanded.css +1 -1
- data/test/sass/results/import.css +1 -1
- data/test/sass/results/import_charset_ibm866.css +2 -2
- data/test/sass/results/mixins.css +17 -17
- data/test/sass/results/nested.css +1 -1
- data/test/sass/results/parent_ref.css +2 -2
- data/test/sass/results/script.css +3 -3
- data/test/sass/results/scss_import.css +1 -1
- data/test/sass/script_conversion_test.rb +10 -7
- data/test/sass/script_test.rb +288 -74
- data/test/sass/scss/css_test.rb +141 -24
- data/test/sass/scss/rx_test.rb +4 -4
- data/test/sass/scss/scss_test.rb +457 -18
- data/test/sass/source_map_test.rb +115 -25
- data/test/sass/superselector_test.rb +191 -0
- data/test/sass/templates/scss_import.scss +2 -1
- data/test/sass/test_helper.rb +1 -1
- data/test/sass/util/multibyte_string_scanner_test.rb +1 -1
- data/test/sass/util/normalized_map_test.rb +1 -1
- data/test/sass/util/subset_map_test.rb +2 -2
- data/test/sass/util_test.rb +31 -1
- data/test/sass/value_helpers_test.rb +5 -7
- data/test/test_helper.rb +2 -2
- data/vendor/listen/CHANGELOG.md +1 -228
- data/vendor/listen/Gemfile +5 -15
- data/vendor/listen/README.md +111 -77
- data/vendor/listen/Rakefile +0 -42
- data/vendor/listen/lib/listen/adapter.rb +195 -82
- data/vendor/listen/lib/listen/adapters/bsd.rb +27 -64
- data/vendor/listen/lib/listen/adapters/darwin.rb +21 -58
- data/vendor/listen/lib/listen/adapters/linux.rb +23 -55
- data/vendor/listen/lib/listen/adapters/polling.rb +25 -34
- data/vendor/listen/lib/listen/adapters/windows.rb +50 -46
- data/vendor/listen/lib/listen/directory_record.rb +96 -61
- data/vendor/listen/lib/listen/listener.rb +135 -37
- data/vendor/listen/lib/listen/turnstile.rb +9 -5
- data/vendor/listen/lib/listen/version.rb +1 -1
- data/vendor/listen/lib/listen.rb +33 -19
- data/vendor/listen/listen.gemspec +6 -0
- data/vendor/listen/spec/listen/adapter_spec.rb +43 -77
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +8 -8
- data/vendor/listen/spec/listen/directory_record_spec.rb +81 -56
- data/vendor/listen/spec/listen/listener_spec.rb +128 -39
- data/vendor/listen/spec/listen_spec.rb +15 -21
- data/vendor/listen/spec/spec_helper.rb +4 -0
- data/vendor/listen/spec/support/adapter_helper.rb +52 -15
- data/vendor/listen/spec/support/directory_record_helper.rb +7 -5
- data/vendor/listen/spec/support/listeners_helper.rb +30 -7
- metadata +25 -22
- data/ext/mkrf_conf.rb +0 -27
- data/lib/sass/importers/deprecated_path.rb +0 -51
- data/lib/sass/script/value/deprecated_false.rb +0 -55
- data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
- data/vendor/listen/lib/listen/multi_listener.rb +0 -143
- data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
- data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -174
data/test/sass/scss/scss_test.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
require File.dirname(__FILE__) + '/test_helper'
|
4
4
|
|
5
|
-
class ScssTest < Test
|
5
|
+
class ScssTest < MiniTest::Test
|
6
6
|
include ScssTestHelper
|
7
7
|
|
8
8
|
## One-Line Comments
|
@@ -115,6 +115,14 @@ SCSS
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
def test_error_directive
|
119
|
+
assert_raise_message(Sass::SyntaxError, "hello world!") {render(<<SCSS)}
|
120
|
+
foo {a: b}
|
121
|
+
@error "hello world!";
|
122
|
+
bar {c: d}
|
123
|
+
SCSS
|
124
|
+
end
|
125
|
+
|
118
126
|
def test_warn_directive
|
119
127
|
expected_warning = <<EXPECTATION
|
120
128
|
WARNING: this is a warning
|
@@ -536,11 +544,17 @@ foo :baz {
|
|
536
544
|
c: d; }
|
537
545
|
foo bang:bop {
|
538
546
|
e: f; }
|
547
|
+
foo ::qux {
|
548
|
+
g: h; }
|
549
|
+
foo zap::fblthp {
|
550
|
+
i: j; }
|
539
551
|
CSS
|
540
552
|
foo {
|
541
553
|
.bar {a: b}
|
542
554
|
:baz {c: d}
|
543
|
-
bang:bop {e: f}
|
555
|
+
bang:bop {e: f}
|
556
|
+
::qux {g: h}
|
557
|
+
zap::fblthp {i: j}}
|
544
558
|
SCSS
|
545
559
|
end
|
546
560
|
|
@@ -645,7 +659,7 @@ SCSS
|
|
645
659
|
end
|
646
660
|
|
647
661
|
def test_parent_selector_with_subject
|
648
|
-
assert_equal <<CSS, render(<<SCSS)
|
662
|
+
silence_warnings {assert_equal <<CSS, render(<<SCSS)}
|
649
663
|
bar foo.baz! .bip {
|
650
664
|
a: b; }
|
651
665
|
|
@@ -799,18 +813,27 @@ SCSS
|
|
799
813
|
def test_no_namespace_properties_without_space_even_when_its_unambiguous
|
800
814
|
render(<<SCSS)
|
801
815
|
foo {
|
802
|
-
bar:
|
816
|
+
bar:baz calc(1 + 2) {
|
803
817
|
bip: bop }}
|
804
818
|
SCSS
|
805
819
|
assert(false, "Expected syntax error")
|
806
820
|
rescue Sass::SyntaxError => e
|
807
|
-
assert_equal
|
808
|
-
Invalid CSS: a space is required between a property and its definition
|
809
|
-
when it has other properties nested beneath it.
|
810
|
-
MESSAGE
|
821
|
+
assert_equal 'Invalid CSS after "bar:baz calc": expected selector, was "(1 + 2)"', e.message
|
811
822
|
assert_equal 2, e.sass_line
|
812
823
|
end
|
813
824
|
|
825
|
+
def test_namespace_properties_without_space_allowed_for_non_identifier
|
826
|
+
assert_equal <<CSS, render(<<SCSS)
|
827
|
+
foo {
|
828
|
+
bar: 1px;
|
829
|
+
bar-bip: bop; }
|
830
|
+
CSS
|
831
|
+
foo {
|
832
|
+
bar:1px {
|
833
|
+
bip: bop }}
|
834
|
+
SCSS
|
835
|
+
end
|
836
|
+
|
814
837
|
## Mixins
|
815
838
|
|
816
839
|
def test_basic_mixins
|
@@ -903,6 +926,33 @@ CSS
|
|
903
926
|
SCSS
|
904
927
|
end
|
905
928
|
|
929
|
+
def test_keyframes_rules_in_content
|
930
|
+
assert_equal <<CSS, render(<<SCSS)
|
931
|
+
@keyframes identifier {
|
932
|
+
0% {
|
933
|
+
top: 0;
|
934
|
+
left: 0; }
|
935
|
+
30% {
|
936
|
+
top: 50px; }
|
937
|
+
68%, 72% {
|
938
|
+
left: 50px; }
|
939
|
+
100% {
|
940
|
+
top: 100px;
|
941
|
+
left: 100%; } }
|
942
|
+
CSS
|
943
|
+
@mixin keyframes {
|
944
|
+
@keyframes identifier { @content }
|
945
|
+
}
|
946
|
+
|
947
|
+
@include keyframes {
|
948
|
+
0% {top: 0; left: 0}
|
949
|
+
\#{"30%"} {top: 50px}
|
950
|
+
68%, 72% {left: 50px}
|
951
|
+
100% {top: 100px; left: 100%}
|
952
|
+
}
|
953
|
+
SCSS
|
954
|
+
end
|
955
|
+
|
906
956
|
## Functions
|
907
957
|
|
908
958
|
def test_basic_function
|
@@ -1884,10 +1934,10 @@ SCSS
|
|
1884
1934
|
|
1885
1935
|
def test_basic_selector_interpolation
|
1886
1936
|
assert_equal <<CSS, render(<<SCSS)
|
1887
|
-
foo
|
1937
|
+
foo ab baz {
|
1888
1938
|
a: b; }
|
1889
1939
|
CSS
|
1890
|
-
foo \#{
|
1940
|
+
foo \#{'a' + 'b'} baz {a: b}
|
1891
1941
|
SCSS
|
1892
1942
|
assert_equal <<CSS, render(<<SCSS)
|
1893
1943
|
foo.bar baz {
|
@@ -2013,7 +2063,7 @@ SCSS
|
|
2013
2063
|
end
|
2014
2064
|
|
2015
2065
|
def test_parent_selector_with_parent_and_subject
|
2016
|
-
assert_equal <<CSS, render(<<SCSS)
|
2066
|
+
silence_warnings {assert_equal <<CSS, render(<<SCSS)}
|
2017
2067
|
bar foo.baz! .bip {
|
2018
2068
|
c: d; }
|
2019
2069
|
CSS
|
@@ -2186,6 +2236,69 @@ $domain: "sass-lang.com";
|
|
2186
2236
|
SCSS
|
2187
2237
|
end
|
2188
2238
|
|
2239
|
+
def test_color_interpolation_warning_in_selector
|
2240
|
+
assert_warning(<<WARNING) {assert_equal <<CSS, render(<<SCSS)}
|
2241
|
+
WARNING on line 1, column 4 of #{filename_for_test(:scss)}:
|
2242
|
+
You probably don't mean to use the color value `blue' in interpolation here.
|
2243
|
+
It may end up represented as #0000ff, which will likely produce invalid CSS.
|
2244
|
+
Always quote color names when using them as strings (for example, "blue").
|
2245
|
+
If you really want to use the color value here, use `"" + blue'.
|
2246
|
+
WARNING
|
2247
|
+
fooblue {
|
2248
|
+
a: b; }
|
2249
|
+
CSS
|
2250
|
+
foo\#{blue} {a: b}
|
2251
|
+
SCSS
|
2252
|
+
end
|
2253
|
+
|
2254
|
+
def test_color_interpolation_warning_in_directive
|
2255
|
+
assert_warning(<<WARNING) {assert_equal <<CSS, render(<<SCSS)}
|
2256
|
+
WARNING on line 1, column 12 of #{filename_for_test(:scss)}:
|
2257
|
+
You probably don't mean to use the color value `blue' in interpolation here.
|
2258
|
+
It may end up represented as #0000ff, which will likely produce invalid CSS.
|
2259
|
+
Always quote color names when using them as strings (for example, "blue").
|
2260
|
+
If you really want to use the color value here, use `"" + blue'.
|
2261
|
+
WARNING
|
2262
|
+
@fblthp fooblue {
|
2263
|
+
a: b; }
|
2264
|
+
CSS
|
2265
|
+
@fblthp foo\#{blue} {a: b}
|
2266
|
+
SCSS
|
2267
|
+
end
|
2268
|
+
|
2269
|
+
def test_color_interpolation_warning_in_property_name
|
2270
|
+
assert_warning(<<WARNING) {assert_equal <<CSS, render(<<SCSS)}
|
2271
|
+
WARNING on line 1, column 8 of #{filename_for_test(:scss)}:
|
2272
|
+
You probably don't mean to use the color value `blue' in interpolation here.
|
2273
|
+
It may end up represented as #0000ff, which will likely produce invalid CSS.
|
2274
|
+
Always quote color names when using them as strings (for example, "blue").
|
2275
|
+
If you really want to use the color value here, use `"" + blue'.
|
2276
|
+
WARNING
|
2277
|
+
foo {
|
2278
|
+
a-blue: b; }
|
2279
|
+
CSS
|
2280
|
+
foo {a-\#{blue}: b}
|
2281
|
+
SCSS
|
2282
|
+
end
|
2283
|
+
|
2284
|
+
def test_no_color_interpolation_warning_in_property_value
|
2285
|
+
assert_no_warning {assert_equal <<CSS, render(<<SCSS)}
|
2286
|
+
foo {
|
2287
|
+
a: b-blue; }
|
2288
|
+
CSS
|
2289
|
+
foo {a: b-\#{blue}}
|
2290
|
+
SCSS
|
2291
|
+
end
|
2292
|
+
|
2293
|
+
def test_no_color_interpolation_warning_for_nameless_color
|
2294
|
+
assert_no_warning {assert_equal <<CSS, render(<<SCSS)}
|
2295
|
+
foo-#abcdef {
|
2296
|
+
a: b; }
|
2297
|
+
CSS
|
2298
|
+
foo-\#{#abcdef} {a: b}
|
2299
|
+
SCSS
|
2300
|
+
end
|
2301
|
+
|
2189
2302
|
def test_nested_mixin_def
|
2190
2303
|
assert_equal <<CSS, render(<<SCSS)
|
2191
2304
|
foo {
|
@@ -2848,8 +2961,283 @@ CSS
|
|
2848
2961
|
SCSS
|
2849
2962
|
end
|
2850
2963
|
|
2964
|
+
def test_at_root_without_keyframes_in_keyframe_rule
|
2965
|
+
assert_equal <<CSS, render(<<SCSS)
|
2966
|
+
.foo {
|
2967
|
+
a: b; }
|
2968
|
+
CSS
|
2969
|
+
@keyframes identifier {
|
2970
|
+
0% {
|
2971
|
+
@at-root (without: keyframes) {
|
2972
|
+
.foo {a: b}
|
2973
|
+
}
|
2974
|
+
}
|
2975
|
+
}
|
2976
|
+
SCSS
|
2977
|
+
end
|
2978
|
+
|
2979
|
+
def test_at_root_without_rule_in_keyframe_rule
|
2980
|
+
assert_equal <<CSS, render(<<SCSS)
|
2981
|
+
@keyframes identifier {
|
2982
|
+
0% {
|
2983
|
+
a: b; } }
|
2984
|
+
CSS
|
2985
|
+
@keyframes identifier {
|
2986
|
+
0% {
|
2987
|
+
@at-root (without: rule) {a: b}
|
2988
|
+
}
|
2989
|
+
}
|
2990
|
+
SCSS
|
2991
|
+
end
|
2992
|
+
|
2993
|
+
## Selector Script
|
2994
|
+
|
2995
|
+
def test_selector_script
|
2996
|
+
assert_equal(<<CSS, render(<<SCSS))
|
2997
|
+
.foo .bar {
|
2998
|
+
content: ".foo .bar"; }
|
2999
|
+
CSS
|
3000
|
+
.foo .bar {
|
3001
|
+
content: "\#{&}";
|
3002
|
+
}
|
3003
|
+
SCSS
|
3004
|
+
end
|
3005
|
+
|
3006
|
+
def test_nested_selector_script
|
3007
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3008
|
+
.foo .bar {
|
3009
|
+
content: ".foo .bar"; }
|
3010
|
+
CSS
|
3011
|
+
.foo {
|
3012
|
+
.bar {
|
3013
|
+
content: "\#{&}";
|
3014
|
+
}
|
3015
|
+
}
|
3016
|
+
SCSS
|
3017
|
+
end
|
3018
|
+
|
3019
|
+
def test_nested_selector_script_with_outer_comma_selector
|
3020
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3021
|
+
.foo .baz, .bar .baz {
|
3022
|
+
content: ".foo .baz, .bar .baz"; }
|
3023
|
+
CSS
|
3024
|
+
.foo, .bar {
|
3025
|
+
.baz {
|
3026
|
+
content: "\#{&}";
|
3027
|
+
}
|
3028
|
+
}
|
3029
|
+
SCSS
|
3030
|
+
end
|
3031
|
+
|
3032
|
+
def test_nested_selector_script_with_inner_comma_selector
|
3033
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3034
|
+
.foo .bar, .foo .baz {
|
3035
|
+
content: ".foo .bar, .foo .baz"; }
|
3036
|
+
CSS
|
3037
|
+
.foo {
|
3038
|
+
.bar, .baz {
|
3039
|
+
content: "\#{&}";
|
3040
|
+
}
|
3041
|
+
}
|
3042
|
+
SCSS
|
3043
|
+
end
|
3044
|
+
|
3045
|
+
def test_selector_script_through_mixin
|
3046
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3047
|
+
.foo {
|
3048
|
+
content: ".foo"; }
|
3049
|
+
CSS
|
3050
|
+
@mixin mixin {
|
3051
|
+
content: "\#{&}";
|
3052
|
+
}
|
3053
|
+
|
3054
|
+
.foo {
|
3055
|
+
@include mixin;
|
3056
|
+
}
|
3057
|
+
SCSS
|
3058
|
+
end
|
3059
|
+
|
3060
|
+
def test_selector_script_through_content
|
3061
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3062
|
+
.foo {
|
3063
|
+
content: ".foo"; }
|
3064
|
+
CSS
|
3065
|
+
@mixin mixin {
|
3066
|
+
@content;
|
3067
|
+
}
|
3068
|
+
|
3069
|
+
.foo {
|
3070
|
+
@include mixin {
|
3071
|
+
content: "\#{&}";
|
3072
|
+
}
|
3073
|
+
}
|
3074
|
+
SCSS
|
3075
|
+
end
|
3076
|
+
|
3077
|
+
def test_selector_script_through_function
|
3078
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3079
|
+
.foo {
|
3080
|
+
content: ".foo"; }
|
3081
|
+
CSS
|
3082
|
+
@function fn() {
|
3083
|
+
@return "\#{&}";
|
3084
|
+
}
|
3085
|
+
|
3086
|
+
.foo {
|
3087
|
+
content: fn();
|
3088
|
+
}
|
3089
|
+
SCSS
|
3090
|
+
end
|
3091
|
+
|
3092
|
+
def test_selector_script_through_media
|
3093
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3094
|
+
.foo {
|
3095
|
+
content: "outer"; }
|
3096
|
+
@media screen {
|
3097
|
+
.foo .bar {
|
3098
|
+
content: ".foo .bar"; } }
|
3099
|
+
CSS
|
3100
|
+
.foo {
|
3101
|
+
content: "outer";
|
3102
|
+
@media screen {
|
3103
|
+
.bar {
|
3104
|
+
content: "\#{&}";
|
3105
|
+
}
|
3106
|
+
}
|
3107
|
+
}
|
3108
|
+
SCSS
|
3109
|
+
end
|
3110
|
+
|
3111
|
+
def test_selector_script_save_and_reuse
|
3112
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3113
|
+
.bar {
|
3114
|
+
content: ".foo"; }
|
3115
|
+
CSS
|
3116
|
+
$var: null;
|
3117
|
+
.foo {
|
3118
|
+
$var: & !global;
|
3119
|
+
}
|
3120
|
+
|
3121
|
+
.bar {
|
3122
|
+
content: "\#{$var}";
|
3123
|
+
}
|
3124
|
+
SCSS
|
3125
|
+
end
|
3126
|
+
|
3127
|
+
def test_selector_script_with_at_root
|
3128
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3129
|
+
.foo-bar {
|
3130
|
+
a: b; }
|
3131
|
+
CSS
|
3132
|
+
.foo {
|
3133
|
+
@at-root \#{&}-bar {
|
3134
|
+
a: b;
|
3135
|
+
}
|
3136
|
+
}
|
3137
|
+
SCSS
|
3138
|
+
end
|
3139
|
+
|
3140
|
+
def test_multi_level_at_root_with_inner_selector_script
|
3141
|
+
assert_equal <<CSS, render(<<SCSS)
|
3142
|
+
.bar {
|
3143
|
+
a: b; }
|
3144
|
+
CSS
|
3145
|
+
.foo {
|
3146
|
+
@at-root .bar {
|
3147
|
+
@at-root \#{&} {
|
3148
|
+
a: b;
|
3149
|
+
}
|
3150
|
+
}
|
3151
|
+
}
|
3152
|
+
SCSS
|
3153
|
+
end
|
3154
|
+
|
3155
|
+
def test_at_root_with_at_root_through_mixin
|
3156
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3157
|
+
.bar-baz {
|
3158
|
+
a: b; }
|
3159
|
+
CSS
|
3160
|
+
@mixin foo {
|
3161
|
+
.bar {
|
3162
|
+
@at-root \#{&}-baz {
|
3163
|
+
a: b;
|
3164
|
+
}
|
3165
|
+
}
|
3166
|
+
}
|
3167
|
+
|
3168
|
+
@include foo;
|
3169
|
+
SCSS
|
3170
|
+
end
|
3171
|
+
|
3172
|
+
# See https://github.com/sass/sass/issues/1294
|
3173
|
+
def test_extend_top_leveled_by_at_root
|
3174
|
+
render(<<SCSS)
|
3175
|
+
.span-10 {
|
3176
|
+
@at-root (without: all) {
|
3177
|
+
@extend %column;
|
3178
|
+
}
|
3179
|
+
}
|
3180
|
+
SCSS
|
3181
|
+
|
3182
|
+
assert(false, "Expected syntax error")
|
3183
|
+
rescue Sass::SyntaxError => e
|
3184
|
+
assert_equal "Extend directives may only be used within rules.", e.message
|
3185
|
+
assert_equal 3, e.sass_line
|
3186
|
+
end
|
3187
|
+
|
3188
|
+
def test_at_root_doesnt_always_break_blocks
|
3189
|
+
assert_equal <<CSS, render(<<SCSS)
|
3190
|
+
.foo {
|
3191
|
+
a: b; }
|
3192
|
+
|
3193
|
+
@media screen {
|
3194
|
+
.foo {
|
3195
|
+
c: d; }
|
3196
|
+
.bar {
|
3197
|
+
e: f; } }
|
3198
|
+
CSS
|
3199
|
+
%base {
|
3200
|
+
a: b;
|
3201
|
+
}
|
3202
|
+
|
3203
|
+
@media screen {
|
3204
|
+
.foo {
|
3205
|
+
c: d;
|
3206
|
+
@at-root (without: media) {
|
3207
|
+
@extend %base;
|
3208
|
+
}
|
3209
|
+
}
|
3210
|
+
|
3211
|
+
.bar {e: f}
|
3212
|
+
}
|
3213
|
+
SCSS
|
3214
|
+
end
|
3215
|
+
|
2851
3216
|
## Errors
|
2852
3217
|
|
3218
|
+
def test_keyframes_rule_outside_of_keyframes
|
3219
|
+
render <<SCSS
|
3220
|
+
0% {
|
3221
|
+
top: 0; }
|
3222
|
+
SCSS
|
3223
|
+
assert(false, "Expected syntax error")
|
3224
|
+
rescue Sass::SyntaxError => e
|
3225
|
+
assert_equal 'Invalid CSS after "": expected selector, was "0%"', e.message
|
3226
|
+
assert_equal 1, e.sass_line
|
3227
|
+
end
|
3228
|
+
|
3229
|
+
def test_selector_rule_in_keyframes
|
3230
|
+
render <<SCSS
|
3231
|
+
@keyframes identifier {
|
3232
|
+
.foo {
|
3233
|
+
top: 0; } }
|
3234
|
+
SCSS
|
3235
|
+
assert(false, "Expected syntax error")
|
3236
|
+
rescue Sass::SyntaxError => e
|
3237
|
+
assert_equal 'Invalid CSS after "": expected keyframes selector (e.g. 10%), was ".foo"', e.message
|
3238
|
+
assert_equal 2, e.sass_line
|
3239
|
+
end
|
3240
|
+
|
2853
3241
|
def test_nested_mixin_def_is_scoped
|
2854
3242
|
render <<SCSS
|
2855
3243
|
foo {
|
@@ -2904,7 +3292,7 @@ foo {
|
|
2904
3292
|
SCSS
|
2905
3293
|
assert(false, "Expected syntax error")
|
2906
3294
|
rescue Sass::SyntaxError => e
|
2907
|
-
assert_equal 'Invalid CSS after " .bar:baz ": expected
|
3295
|
+
assert_equal 'Invalid CSS after " .bar:baz <fail>": expected expression (e.g. 1px, bold), was "; }"', e.message
|
2908
3296
|
assert_equal 2, e.sass_line
|
2909
3297
|
end
|
2910
3298
|
|
@@ -3014,7 +3402,7 @@ SCSS
|
|
3014
3402
|
|
3015
3403
|
def test_parent_in_mid_selector_error
|
3016
3404
|
assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render <<SCSS}
|
3017
|
-
Invalid CSS after "
|
3405
|
+
Invalid CSS after ".foo": expected "{", was "&.bar"
|
3018
3406
|
|
3019
3407
|
"&.bar" may only be used at the beginning of a compound selector.
|
3020
3408
|
MESSAGE
|
@@ -3026,7 +3414,7 @@ SCSS
|
|
3026
3414
|
|
3027
3415
|
def test_parent_after_selector_error
|
3028
3416
|
assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render <<SCSS}
|
3029
|
-
Invalid CSS after "
|
3417
|
+
Invalid CSS after ".foo.bar": expected "{", was "&"
|
3030
3418
|
|
3031
3419
|
"&" may only be used at the beginning of a compound selector.
|
3032
3420
|
MESSAGE
|
@@ -3038,7 +3426,7 @@ SCSS
|
|
3038
3426
|
|
3039
3427
|
def test_double_parent_selector_error
|
3040
3428
|
assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render <<SCSS}
|
3041
|
-
Invalid CSS after "
|
3429
|
+
Invalid CSS after "&": expected "{", was "&"
|
3042
3430
|
|
3043
3431
|
"&" may only be used at the beginning of a compound selector.
|
3044
3432
|
MESSAGE
|
@@ -3098,8 +3486,59 @@ MESSAGE
|
|
3098
3486
|
SCSS
|
3099
3487
|
end
|
3100
3488
|
|
3489
|
+
def test_empty_media_query_error
|
3490
|
+
assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render(<<SCSS)}
|
3491
|
+
Invalid CSS after "": expected media query list, was ""
|
3492
|
+
MESSAGE
|
3493
|
+
@media \#{""} {
|
3494
|
+
foo {a: b}
|
3495
|
+
}
|
3496
|
+
SCSS
|
3497
|
+
end
|
3498
|
+
|
3499
|
+
def test_newline_in_property_value
|
3500
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3501
|
+
.foo {
|
3502
|
+
bar: "bazbang"; }
|
3503
|
+
CSS
|
3504
|
+
.foo {
|
3505
|
+
$var: "baz\\
|
3506
|
+
bang";
|
3507
|
+
bar: $var;
|
3508
|
+
}
|
3509
|
+
SCSS
|
3510
|
+
end
|
3511
|
+
|
3512
|
+
def test_raw_newline_warning
|
3513
|
+
assert_warning(<<MESSAGE.rstrip) {assert_equal(<<CSS, render(<<SCSS))}
|
3514
|
+
DEPRECATION WARNING on line 2, column 9 of #{filename_for_test :scss}:
|
3515
|
+
Unescaped multiline strings are deprecated and will be removed in a future version of Sass.
|
3516
|
+
To include a newline in a string, use "\\a" or "\\a " as in CSS.
|
3517
|
+
MESSAGE
|
3518
|
+
.foo {
|
3519
|
+
bar: "baz\\a bang"; }
|
3520
|
+
CSS
|
3521
|
+
.foo {
|
3522
|
+
$var: "baz
|
3523
|
+
bang";
|
3524
|
+
bar: $var;
|
3525
|
+
}
|
3526
|
+
SCSS
|
3527
|
+
end
|
3528
|
+
|
3101
3529
|
# Regression
|
3102
|
-
|
3530
|
+
|
3531
|
+
def test_top_level_unknown_directive_in_at_root
|
3532
|
+
assert_equal(<<CSS, render(<<SCSS))
|
3533
|
+
@fblthp {
|
3534
|
+
a: b; }
|
3535
|
+
CSS
|
3536
|
+
@at-root {
|
3537
|
+
@fblthp {a: b}
|
3538
|
+
}
|
3539
|
+
SCSS
|
3540
|
+
end
|
3541
|
+
|
3103
3542
|
def test_parent_ref_with_newline
|
3104
3543
|
assert_equal(<<CSS, render(<<SCSS))
|
3105
3544
|
a.c
|
@@ -3422,10 +3861,10 @@ SCSS
|
|
3422
3861
|
}
|
3423
3862
|
.aaa .aaa .aaa {
|
3424
3863
|
background-color: black;
|
3425
|
-
}
|
3864
|
+
}
|
3426
3865
|
.bbb {
|
3427
3866
|
@extend .aaa;
|
3428
|
-
}
|
3867
|
+
}
|
3429
3868
|
.xxx {
|
3430
3869
|
@extend .bbb;
|
3431
3870
|
}
|