From 5962a85a99ba22b7332992e0c7f49576a95bd1a7 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 24 Apr 2011 18:59:07 -0700 Subject: [PATCH] Fix broken linear gradients with svg enabled. --- .../sass_extensions/functions/gradient_support.rb | 7 +++++-- test/fixtures/stylesheets/compass/css/gradients.css | 12 +++++++----- .../fixtures/stylesheets/compass/sass/gradients.sass | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/compass/sass_extensions/functions/gradient_support.rb b/lib/compass/sass_extensions/functions/gradient_support.rb index d5070468..17af3ad7 100644 --- a/lib/compass/sass_extensions/functions/gradient_support.rb +++ b/lib/compass/sass_extensions/functions/gradient_support.rb @@ -62,7 +62,10 @@ module Compass::SassExtensions::Functions::GradientSupport end def angle?(value) - value.is_a?(Sass::Script::Number) && value.numerator_units.size == 1 && value.numerator_units.first == "deg" && value.denominator_units.empty? + value.is_a?(Sass::Script::Number) && + value.numerator_units.size == 1 && + value.numerator_units.first == "deg" && + value.denominator_units.empty? end end @@ -457,7 +460,7 @@ module Compass::SassExtensions::Functions::GradientSupport def linear_svg(color_stops, x1, y1, x2, y2) transform = '' - if angle? + if angle?(position_or_angle) transform = %Q{ gradientTransform = "rotate(#{position_or_angle.value})"} end gradient = %Q{#{color_stops_svg(color_stops)}} diff --git a/test/fixtures/stylesheets/compass/css/gradients.css b/test/fixtures/stylesheets/compass/css/gradients.css index e3a03057..57aa979b 100644 --- a/test/fixtures/stylesheets/compass/css/gradients.css +++ b/test/fixtures/stylesheets/compass/css/gradients.css @@ -93,11 +93,13 @@ background-image: linear-gradient(-45deg, #dddddd, #aaaaaa); } .bg-radial-gradient-with-angle-and-shape { - background-image: -webkit-gradient(radial, 45deg, 0, 45deg, 100, color-stop(0%, #dddddd), color-stop(100%, #aaaaaa)); - background-image: -webkit-radial-gradient(45deg, ellipse cover, #dddddd, #aaaaaa 100px); - background-image: -moz-radial-gradient(45deg, ellipse cover, #dddddd, #aaaaaa 100px); - background-image: -o-radial-gradient(45deg, ellipse cover, #dddddd, #aaaaaa 100px); - background-image: radial-gradient(45deg, ellipse cover, #dddddd, #aaaaaa 100px); } + background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9ImVsbGlwc2UiIGN5PSJjb3ZlciIgcj0iMTAwIj48c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZGRkZGRkIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjYWFhYWFhIi8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g'); + background-size: 100%; + background-image: -webkit-gradient(radial, ellipse cover, 0, ellipse cover, 100, color-stop(0%, #dddddd), color-stop(100%, #aaaaaa)); + background-image: -webkit-radial-gradient(ellipse cover, #dddddd, #aaaaaa 100px); + background-image: -moz-radial-gradient(ellipse cover, #dddddd, #aaaaaa 100px); + background-image: -o-radial-gradient(ellipse cover, #dddddd, #aaaaaa 100px); + background-image: radial-gradient(ellipse cover, #dddddd, #aaaaaa 100px); } .bg-all-gradient-types { background-image: url('/images/4x6.png?busted=true'), url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2RkZGRkZCIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2FhYWFhYSIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA=='), url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iMTAwIj48c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZGRkZGRkIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjYWFhYWFhIi8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g'); diff --git a/test/fixtures/stylesheets/compass/sass/gradients.sass b/test/fixtures/stylesheets/compass/sass/gradients.sass index 5a27bbc2..dc915aa4 100644 --- a/test/fixtures/stylesheets/compass/sass/gradients.sass +++ b/test/fixtures/stylesheets/compass/sass/gradients.sass @@ -38,7 +38,7 @@ $experimental-support-for-svg: true +background-image(linear-gradient(-45deg, #ddd, #aaa)) .bg-radial-gradient-with-angle-and-shape - +background-image(radial-gradient(45deg, ellipse cover, #ddd, #aaa 100px)) + +background-image(radial-gradient(ellipse cover, #ddd, #aaa 100px)) .bg-all-gradient-types +background-image(image-url("4x6.png"), linear-gradient(top left, #ddd, #aaa), radial-gradient(center center, #ddd, #aaa 100px))