Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Omit properties with empty resolved values.

  • Loading branch information...
commit 7e0d57a1fa41d1c4e8fbd48bc551c7aeaafdcf2d 1 parent 0072cce
@petebrowne authored
View
2  lib/sass/tree/prop_node.rb
@@ -98,7 +98,7 @@ def check!
if @options[:property_syntax] && @options[:property_syntax] != @prop_syntax
raise Sass::SyntaxError.new(
"Illegal property syntax: can't use #{@prop_syntax} syntax when :property_syntax => #{@options[:property_syntax].inspect} is set.")
- elsif resolved_value.empty?
+ elsif value.is_a?(Sass::Script::String) && value.to_s.empty?
raise Sass::SyntaxError.new("Invalid property: #{declaration.dump} (no value)." +
pseudo_class_selector_message)
end
View
7 lib/sass/tree/visitors/to_css.rb
@@ -122,6 +122,7 @@ def visit_cssimport(node)
end
def visit_prop(node)
+ return if node.resolved_value =~ /\A[\s'"()]*\Z/
tab_str = ' ' * (@tabs + node.tabs)
if node.style == :compressed
"#{tab_str}#{node.resolved_name}:#{node.resolved_value}"
@@ -188,13 +189,13 @@ def visit_rule(node)
end
if node.style == :compact
- properties = with_tabs(0) {node.children.map {|a| visit(a)}.join(' ')}
+ properties = with_tabs(0) {node.children.map {|a| visit(a)}.compact.join(' ')}
to_return << "#{total_rule} { #{properties} }#{"\n" if node.group_end}"
elsif node.style == :compressed
- properties = with_tabs(0) {node.children.map {|a| visit(a)}.join(';')}
+ properties = with_tabs(0) {node.children.map {|a| visit(a)}.compact.join(';')}
to_return << "#{total_rule}{#{properties}}"
else
- properties = with_tabs(@tabs + 1) {node.children.map {|a| visit(a)}.join("\n")}
+ properties = with_tabs(@tabs + 1) {node.children.map {|a| visit(a)}.compact.join("\n")}
end_props = (node.style == :expanded ? "\n" + old_spaces : ' ')
to_return << "#{total_rule} {\n#{properties}#{end_props}}#{"\n" if node.group_end}"
end
View
21 test/sass/engine_test.rb
@@ -1011,7 +1011,7 @@ def test_debug_info
def test_debug_info_without_filename
assert_equal(<<CSS, Sass::Engine.new(<<SASS, :debug_info => true).render)
-@media -sass-debug-info{filename{font-family:}line{font-family:\\000031}}
+@media -sass-debug-info{filename{}line{font-family:\\000031}}
foo {
a: b; }
CSS
@@ -1773,11 +1773,20 @@ def test_empty_selector_warning
END
end
- def test_empty_property_error
- assert_raise_message(Sass::SyntaxError, 'Invalid property: "b:" (no value).') {
- render("a\n b: null", :property_syntax => :new) }
- assert_raise_message(Sass::SyntaxError, 'Invalid property: "b:" (no value).') {
- render("a\n b: (null, null)", :property_syntax => :new) }
+ def test_nonprinting_empty_property
+ assert_equal(<<CSS, render(<<SASS))
+a {
+ e: f; }
+CSS
+$null-value: null
+$empty-string: ''
+$empty-list: (null)
+a
+ b: $null-value
+ c: $empty-string
+ d: $empty-list
+ e: f
+SASS
end
def test_root_level_pseudo_class_with_new_properties
Please sign in to comment.
Something went wrong with that request. Please try again.