sass 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +58 -50
  4. data/Rakefile +1 -4
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/bin/sass +1 -1
  9. data/bin/scss +1 -1
  10. data/lib/sass/cache_stores/filesystem.rb +6 -2
  11. data/lib/sass/css.rb +1 -3
  12. data/lib/sass/engine.rb +37 -46
  13. data/lib/sass/environment.rb +13 -17
  14. data/lib/sass/error.rb +6 -9
  15. data/lib/sass/exec/base.rb +187 -0
  16. data/lib/sass/exec/sass_convert.rb +264 -0
  17. data/lib/sass/exec/sass_scss.rb +424 -0
  18. data/lib/sass/exec.rb +5 -771
  19. data/lib/sass/features.rb +7 -0
  20. data/lib/sass/importers/base.rb +7 -2
  21. data/lib/sass/importers/filesystem.rb +9 -25
  22. data/lib/sass/importers.rb +0 -1
  23. data/lib/sass/media.rb +1 -4
  24. data/lib/sass/plugin/compiler.rb +200 -83
  25. data/lib/sass/plugin/staleness_checker.rb +1 -1
  26. data/lib/sass/plugin.rb +3 -3
  27. data/lib/sass/script/css_lexer.rb +1 -1
  28. data/lib/sass/script/functions.rb +622 -268
  29. data/lib/sass/script/lexer.rb +99 -34
  30. data/lib/sass/script/parser.rb +24 -23
  31. data/lib/sass/script/tree/funcall.rb +1 -1
  32. data/lib/sass/script/tree/interpolation.rb +20 -2
  33. data/lib/sass/script/tree/selector.rb +26 -0
  34. data/lib/sass/script/tree/string_interpolation.rb +1 -1
  35. data/lib/sass/script/tree.rb +1 -0
  36. data/lib/sass/script/value/base.rb +7 -5
  37. data/lib/sass/script/value/bool.rb +0 -5
  38. data/lib/sass/script/value/color.rb +39 -21
  39. data/lib/sass/script/value/helpers.rb +107 -0
  40. data/lib/sass/script/value/list.rb +0 -15
  41. data/lib/sass/script/value/null.rb +0 -5
  42. data/lib/sass/script/value/number.rb +62 -14
  43. data/lib/sass/script/value/string.rb +59 -11
  44. data/lib/sass/script/value.rb +0 -1
  45. data/lib/sass/scss/css_parser.rb +8 -2
  46. data/lib/sass/scss/parser.rb +190 -328
  47. data/lib/sass/scss/rx.rb +15 -6
  48. data/lib/sass/scss/static_parser.rb +298 -1
  49. data/lib/sass/selector/abstract_sequence.rb +28 -13
  50. data/lib/sass/selector/comma_sequence.rb +92 -13
  51. data/lib/sass/selector/pseudo.rb +256 -0
  52. data/lib/sass/selector/sequence.rb +94 -24
  53. data/lib/sass/selector/simple.rb +14 -25
  54. data/lib/sass/selector/simple_sequence.rb +97 -33
  55. data/lib/sass/selector.rb +57 -194
  56. data/lib/sass/shared.rb +1 -1
  57. data/lib/sass/source/map.rb +26 -12
  58. data/lib/sass/stack.rb +0 -6
  59. data/lib/sass/supports.rb +2 -3
  60. data/lib/sass/tree/at_root_node.rb +1 -0
  61. data/lib/sass/tree/charset_node.rb +1 -1
  62. data/lib/sass/tree/directive_node.rb +8 -2
  63. data/lib/sass/tree/error_node.rb +18 -0
  64. data/lib/sass/tree/extend_node.rb +1 -1
  65. data/lib/sass/tree/function_node.rb +4 -0
  66. data/lib/sass/tree/keyframe_rule_node.rb +15 -0
  67. data/lib/sass/tree/prop_node.rb +1 -1
  68. data/lib/sass/tree/rule_node.rb +12 -7
  69. data/lib/sass/tree/visitors/check_nesting.rb +38 -10
  70. data/lib/sass/tree/visitors/convert.rb +16 -18
  71. data/lib/sass/tree/visitors/cssize.rb +29 -29
  72. data/lib/sass/tree/visitors/deep_copy.rb +5 -0
  73. data/lib/sass/tree/visitors/perform.rb +45 -33
  74. data/lib/sass/tree/visitors/set_options.rb +14 -0
  75. data/lib/sass/tree/visitors/to_css.rb +15 -14
  76. data/lib/sass/util/subset_map.rb +1 -1
  77. data/lib/sass/util.rb +222 -99
  78. data/lib/sass/version.rb +5 -5
  79. data/lib/sass.rb +0 -5
  80. data/test/sass/cache_test.rb +62 -20
  81. data/test/sass/callbacks_test.rb +1 -1
  82. data/test/sass/compiler_test.rb +19 -10
  83. data/test/sass/conversion_test.rb +58 -1
  84. data/test/sass/css2sass_test.rb +23 -4
  85. data/test/sass/encoding_test.rb +219 -0
  86. data/test/sass/engine_test.rb +136 -199
  87. data/test/sass/exec_test.rb +2 -2
  88. data/test/sass/extend_test.rb +236 -19
  89. data/test/sass/functions_test.rb +295 -253
  90. data/test/sass/importer_test.rb +31 -21
  91. data/test/sass/logger_test.rb +1 -1
  92. data/test/sass/more_results/more_import.css +1 -1
  93. data/test/sass/plugin_test.rb +14 -13
  94. data/test/sass/results/compact.css +1 -1
  95. data/test/sass/results/complex.css +4 -4
  96. data/test/sass/results/expanded.css +1 -1
  97. data/test/sass/results/import.css +1 -1
  98. data/test/sass/results/import_charset_ibm866.css +2 -2
  99. data/test/sass/results/mixins.css +17 -17
  100. data/test/sass/results/nested.css +1 -1
  101. data/test/sass/results/parent_ref.css +2 -2
  102. data/test/sass/results/script.css +3 -3
  103. data/test/sass/results/scss_import.css +1 -1
  104. data/test/sass/script_conversion_test.rb +10 -7
  105. data/test/sass/script_test.rb +288 -74
  106. data/test/sass/scss/css_test.rb +141 -24
  107. data/test/sass/scss/rx_test.rb +4 -4
  108. data/test/sass/scss/scss_test.rb +457 -18
  109. data/test/sass/source_map_test.rb +115 -25
  110. data/test/sass/superselector_test.rb +191 -0
  111. data/test/sass/templates/scss_import.scss +2 -1
  112. data/test/sass/test_helper.rb +1 -1
  113. data/test/sass/util/multibyte_string_scanner_test.rb +1 -1
  114. data/test/sass/util/normalized_map_test.rb +1 -1
  115. data/test/sass/util/subset_map_test.rb +2 -2
  116. data/test/sass/util_test.rb +31 -1
  117. data/test/sass/value_helpers_test.rb +5 -7
  118. data/test/test_helper.rb +2 -2
  119. data/vendor/listen/CHANGELOG.md +1 -228
  120. data/vendor/listen/Gemfile +5 -15
  121. data/vendor/listen/README.md +111 -77
  122. data/vendor/listen/Rakefile +0 -42
  123. data/vendor/listen/lib/listen/adapter.rb +195 -82
  124. data/vendor/listen/lib/listen/adapters/bsd.rb +27 -64
  125. data/vendor/listen/lib/listen/adapters/darwin.rb +21 -58
  126. data/vendor/listen/lib/listen/adapters/linux.rb +23 -55
  127. data/vendor/listen/lib/listen/adapters/polling.rb +25 -34
  128. data/vendor/listen/lib/listen/adapters/windows.rb +50 -46
  129. data/vendor/listen/lib/listen/directory_record.rb +96 -61
  130. data/vendor/listen/lib/listen/listener.rb +135 -37
  131. data/vendor/listen/lib/listen/turnstile.rb +9 -5
  132. data/vendor/listen/lib/listen/version.rb +1 -1
  133. data/vendor/listen/lib/listen.rb +33 -19
  134. data/vendor/listen/listen.gemspec +6 -0
  135. data/vendor/listen/spec/listen/adapter_spec.rb +43 -77
  136. data/vendor/listen/spec/listen/adapters/polling_spec.rb +8 -8
  137. data/vendor/listen/spec/listen/directory_record_spec.rb +81 -56
  138. data/vendor/listen/spec/listen/listener_spec.rb +128 -39
  139. data/vendor/listen/spec/listen_spec.rb +15 -21
  140. data/vendor/listen/spec/spec_helper.rb +4 -0
  141. data/vendor/listen/spec/support/adapter_helper.rb +52 -15
  142. data/vendor/listen/spec/support/directory_record_helper.rb +7 -5
  143. data/vendor/listen/spec/support/listeners_helper.rb +30 -7
  144. metadata +25 -22
  145. data/ext/mkrf_conf.rb +0 -27
  146. data/lib/sass/importers/deprecated_path.rb +0 -51
  147. data/lib/sass/script/value/deprecated_false.rb +0 -55
  148. data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
  149. data/vendor/listen/lib/listen/multi_listener.rb +0 -143
  150. data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
  151. data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -174
@@ -6,7 +6,7 @@ require 'sass/scss/css_parser'
6
6
  # These tests just test the parsing of CSS
7
7
  # (both standard and any hacks we intend to support).
8
8
  # Tests of SCSS-specific behavior go in scss_test.rb.
9
- class ScssCssTest < Test::Unit::TestCase
9
+ class ScssCssTest < MiniTest::Test
10
10
  include ScssTestHelper
11
11
 
12
12
  def test_basic_scss
@@ -94,7 +94,7 @@ foo {a /*: b; c */: d}
94
94
  SCSS
95
95
  end
96
96
 
97
- def test_crazy_comments
97
+ def test_crazy_comments
98
98
  # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/t040109-c17-comments-00-b.xht
99
99
  assert_equal <<CSS, render(<<SCSS)
100
100
  /* This is a CSS comment. */
@@ -499,10 +499,24 @@ SCSS
499
499
 
500
500
  def test_import_directive
501
501
  assert_parses '@import "foo.css";'
502
- assert_parses "@import 'foo.css';"
503
502
  assert_parses '@import url("foo.css");'
504
503
  assert_parses "@import url('foo.css');"
505
504
  assert_parses '@import url(foo.css);'
505
+
506
+ assert_equal <<CSS, render(<<SCSS)
507
+ @import "foo.css";
508
+ CSS
509
+ @import 'foo.css';
510
+ SCSS
511
+ end
512
+
513
+ def test_import_directive_with_backslash_newline
514
+ assert_equal <<CSS, render(<<SCSS)
515
+ @import "foobar.css";
516
+ CSS
517
+ @import "foo\\
518
+ bar.css";
519
+ SCSS
506
520
  end
507
521
 
508
522
  def test_string_import_directive_with_media
@@ -653,6 +667,29 @@ CSS
653
667
  SCSS
654
668
  end
655
669
 
670
+ def test_keyframes
671
+ assert_equal <<CSS, render(<<SCSS)
672
+ @keyframes identifier {
673
+ 0% {
674
+ top: 0;
675
+ left: 0; }
676
+ 30% {
677
+ top: 50px; }
678
+ 68%, 72% {
679
+ left: 50px; }
680
+ 100% {
681
+ top: 100px;
682
+ left: 100%; } }
683
+ CSS
684
+ @keyframes identifier {
685
+ 0% {top: 0; left: 0}
686
+ 30% {top: 50px}
687
+ 68%, 72% {left: 50px}
688
+ 100% {top: 100px; left: 100%}
689
+ }
690
+ SCSS
691
+ end
692
+
656
693
  ## Selectors
657
694
 
658
695
  # Taken from http://dev.w3.org/csswg/selectors4/#overview
@@ -662,6 +699,8 @@ SCSS
662
699
  assert_selector_parses('E:not(s)')
663
700
  assert_selector_parses('E:not(s1, s2)')
664
701
  assert_selector_parses('E:matches(s1, s2)')
702
+ assert_selector_parses('E:has(s1, s2)')
703
+ assert_selector_parses('E:has(> s1, > s2)')
665
704
  assert_selector_parses('E.warning')
666
705
  assert_selector_parses('E#myid')
667
706
  assert_selector_parses('E[foo]')
@@ -712,20 +751,22 @@ SCSS
712
751
  assert_selector_parses('E:last-of-type')
713
752
  assert_selector_parses('E:nth-last-of-type(n)')
714
753
  assert_selector_parses('E:only-of-type')
715
- assert_selector_parses('E:nth-match(n of selector)')
716
- assert_selector_parses('E:nth-last-match(n of selector)')
717
- assert_selector_parses('E:column(selector)')
718
- assert_selector_parses('E:nth-column(n)')
719
- assert_selector_parses('E:nth-last-column(n)')
754
+ assert_selector_parses('E:nth-child(n of selector)')
755
+ assert_selector_parses('E:nth-last-child(n of selector)')
756
+ assert_selector_parses('E:nth-child(n)')
757
+ assert_selector_parses('E:nth-last-child(n)')
720
758
  assert_selector_parses('E F')
721
759
  assert_selector_parses('E > F')
722
760
  assert_selector_parses('E + F')
723
761
  assert_selector_parses('E ~ F')
724
762
  assert_selector_parses('E /foo/ F')
725
- assert_selector_parses('E! > F')
763
+ silence_warnings {assert_selector_parses('E! > F')}
726
764
 
727
765
  assert_selector_parses('E /ns|foo/ F')
728
- assert_selector_parses('E /*|foo/ F')
766
+
767
+ # From http://dev.w3.org/csswg/css-scoping-1/
768
+ assert_selector_parses('E:host(s)')
769
+ assert_selector_parses('E:host-context(s)')
729
770
  end
730
771
 
731
772
  # Taken from http://dev.w3.org/csswg/selectors4/#overview, but without element
@@ -734,6 +775,8 @@ SCSS
734
775
  assert_selector_parses(':not(s)')
735
776
  assert_selector_parses(':not(s1, s2)')
736
777
  assert_selector_parses(':matches(s1, s2)')
778
+ assert_selector_parses(':has(s1, s2)')
779
+ assert_selector_parses(':has(> s1, > s2)')
737
780
  assert_selector_parses('.warning')
738
781
  assert_selector_parses('#myid')
739
782
  assert_selector_parses('[foo]')
@@ -784,11 +827,14 @@ SCSS
784
827
  assert_selector_parses(':last-of-type')
785
828
  assert_selector_parses(':nth-last-of-type(n)')
786
829
  assert_selector_parses(':only-of-type')
787
- assert_selector_parses(':nth-match(n of selector)')
788
- assert_selector_parses(':nth-last-match(n of selector)')
789
- assert_selector_parses(':column(selector)')
790
- assert_selector_parses(':nth-column(n)')
791
- assert_selector_parses(':nth-last-column(n)')
830
+ assert_selector_parses(':nth-child(n of selector)')
831
+ assert_selector_parses(':nth-last-child(n of selector)')
832
+ assert_selector_parses(':nth-child(n)')
833
+ assert_selector_parses(':nth-last-child(n)')
834
+
835
+ # From http://dev.w3.org/csswg/css-scoping-1/
836
+ assert_selector_parses(':host(s)')
837
+ assert_selector_parses(':host-context(s)')
792
838
  end
793
839
 
794
840
  def test_attribute_selectors_with_identifiers
@@ -828,15 +874,18 @@ SCSS
828
874
  def test_selectors_containing_selectors
829
875
  assert_selector_can_contain_selectors(':not(<sel>)')
830
876
  assert_selector_can_contain_selectors(':current(<sel>)')
831
- assert_selector_can_contain_selectors(':nth-match(n of <sel>)')
832
- assert_selector_can_contain_selectors(':nth-last-match(n of <sel>)')
833
- assert_selector_can_contain_selectors(':column(<sel>)')
877
+ assert_selector_can_contain_selectors(':nth-child(n of <sel>)')
878
+ assert_selector_can_contain_selectors(':nth-last-child(n of <sel>)')
834
879
  assert_selector_can_contain_selectors(':-moz-any(<sel>)')
880
+ assert_selector_can_contain_selectors(':has(<sel>)')
881
+ assert_selector_can_contain_selectors(':has(+ <sel>)')
882
+ assert_selector_can_contain_selectors(':host(<sel>)')
883
+ assert_selector_can_contain_selectors(':host-context(<sel>)')
835
884
  end
836
885
 
837
886
  def assert_selector_can_contain_selectors(sel)
838
887
  try = lambda {|subsel| assert_selector_parses(sel.gsub('<sel>', subsel))}
839
-
888
+
840
889
  try['foo|bar']
841
890
  try['*|bar']
842
891
 
@@ -888,11 +937,11 @@ SCSS
888
937
  end
889
938
 
890
939
  def test_expression_fallback_selectors
891
- assert_selector_parses('0%')
892
- assert_selector_parses('60%')
893
- assert_selector_parses('100%')
894
- assert_selector_parses('12px')
895
- assert_selector_parses('"foo"')
940
+ assert_directive_parses('0%')
941
+ assert_directive_parses('60%')
942
+ assert_directive_parses('100%')
943
+ assert_directive_parses('12px')
944
+ assert_directive_parses('"foo"')
896
945
  end
897
946
 
898
947
  def test_functional_pseudo_selectors
@@ -929,6 +978,29 @@ SCSS
929
978
  assert_equal "E + F {\n a: b; }\n", render("E+F { a: b;} ")
930
979
  end
931
980
 
981
+ def test_subject_selector_deprecation
982
+ assert_warning(<<WARNING) {render(".foo .bar! .baz {a: b}")}
983
+ DEPRECATION WARNING on line 1, column 1:
984
+ The subject selector operator "!" is deprecated and will be removed in a future release.
985
+ This operator has been replaced by ":has()" in the CSS spec.
986
+ For example: .foo .bar:has(.baz)
987
+ WARNING
988
+
989
+ assert_warning(<<WARNING) {render(".foo .bar! > .baz {a: b}")}
990
+ DEPRECATION WARNING on line 1, column 1:
991
+ The subject selector operator "!" is deprecated and will be removed in a future release.
992
+ This operator has been replaced by ":has()" in the CSS spec.
993
+ For example: .foo .bar:has(> .baz)
994
+ WARNING
995
+
996
+ assert_warning(<<WARNING) {render(".foo .bar! {a: b}")}
997
+ DEPRECATION WARNING on line 1, column 1:
998
+ The subject selector operator "!" is deprecated and will be removed in a future release.
999
+ This operator has been replaced by ":has()" in the CSS spec.
1000
+ For example: .foo .bar
1001
+ WARNING
1002
+ end
1003
+
932
1004
  ## Errors
933
1005
 
934
1006
  def test_invalid_directives
@@ -1014,8 +1086,41 @@ SCSS
1014
1086
  assert_equal 1, e.sass_line
1015
1087
  end
1016
1088
 
1089
+ def test_newline_in_property_value
1090
+ assert_equal(<<CSS, render(<<SCSS))
1091
+ .foo {
1092
+ bar: "bazbang"; }
1093
+ CSS
1094
+ .foo {
1095
+ bar: "baz\\
1096
+ bang";
1097
+ }
1098
+ SCSS
1099
+ end
1100
+
1017
1101
  ## Regressions
1018
1102
 
1103
+ def test_very_long_comment_doesnt_take_forever
1104
+ string = 'asdf' * (100000)
1105
+ assert_equal(<<CSS, render(<<SCSS))
1106
+ /*
1107
+ #{string}
1108
+ */
1109
+ CSS
1110
+ /*
1111
+ #{string}
1112
+ */
1113
+ SCSS
1114
+ end
1115
+
1116
+ def test_long_unclosed_comment_doesnt_take_forever
1117
+ assert_raise_message(Sass::SyntaxError,
1118
+ 'Invalid CSS after "/*": expected "/", was "//*************..."') {render(<<SCSS)}
1119
+ /*
1120
+ //**************************************************************************
1121
+ SCSS
1122
+ end
1123
+
1019
1124
  def test_double_space_string
1020
1125
  assert_equal(<<CSS, render(<<SCSS))
1021
1126
  .a {
@@ -1088,6 +1193,18 @@ SCSS
1088
1193
  #{selector} {
1089
1194
  a: b; }
1090
1195
  SCSS
1196
+
1197
+ assert_parses <<SCSS
1198
+ :not(#{selector}) {
1199
+ a: b; }
1200
+ SCSS
1201
+ end
1202
+
1203
+ def assert_directive_parses(param)
1204
+ assert_parses <<SCSS
1205
+ @keyframes #{param} {
1206
+ a: b; }
1207
+ SCSS
1091
1208
  end
1092
1209
 
1093
1210
  def render(scss, options = {})
@@ -3,7 +3,7 @@
3
3
  require File.dirname(__FILE__) + '/../../test_helper'
4
4
  require 'sass/engine'
5
5
 
6
- class ScssRxTest < Test::Unit::TestCase
6
+ class ScssRxTest < MiniTest::Test
7
7
  include Sass::SCSS::RX
8
8
 
9
9
  def test_identifiers
@@ -26,6 +26,7 @@ class ScssRxTest < Test::Unit::TestCase
26
26
  assert_match IDENT, "_foo" # Can put a _ before anything
27
27
  assert_match IDENT, "_\xC3\xBFoo"
28
28
  assert_match IDENT, "_\\f oo"
29
+ assert_match IDENT, "--foo" # "Custom" identifier
29
30
 
30
31
  assert_match IDENT, "foo-bar"
31
32
  assert_match IDENT, "f012-23"
@@ -59,7 +60,6 @@ class ScssRxTest < Test::Unit::TestCase
59
60
  assert_no_match IDENT, ""
60
61
  assert_no_match IDENT, "1foo"
61
62
  assert_no_match IDENT, "-1foo"
62
- assert_no_match IDENT, "--foo"
63
63
  assert_no_match IDENT, "foo bar"
64
64
  assert_no_match IDENT, "foo~bar"
65
65
 
@@ -144,13 +144,13 @@ class ScssRxTest < Test::Unit::TestCase
144
144
  private
145
145
 
146
146
  def assert_match(rx, str)
147
- assert_not_nil(match = rx.match(str))
147
+ refute_nil(match = rx.match(str))
148
148
  assert_equal str.size, match[0].size
149
149
  end
150
150
 
151
151
  def assert_no_match(rx, str)
152
152
  match = rx.match(str)
153
- assert_not_equal str.size, match && match[0].size
153
+ refute_equal str.size, match && match[0].size
154
154
  end
155
155
 
156
156
  end