From f2ceec4680a2305bf716c5eba2fbc52768ff721e Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Wed, 30 Mar 2011 10:45:27 -0700 Subject: [PATCH] Created a function called css2-fallback($value, $css2-value) that will use the $css2-value in a css2 context and the $value in other contexts. --- doc-src/content/CHANGELOG.markdown | 6 +++- .../content/reference/compass/helpers.haml | 1 + .../compass/helpers/cross-browser.haml | 11 +++++++ .../functions/cross_browser_support.rb | 31 +++++++++++++++++++ test/sass_extensions_test.rb | 6 ++++ 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/doc-src/content/CHANGELOG.markdown b/doc-src/content/CHANGELOG.markdown index 1b6034f4..aa4b0db5 100644 --- a/doc-src/content/CHANGELOG.markdown +++ b/doc-src/content/CHANGELOG.markdown @@ -14,7 +14,11 @@ The Documentation for the [latest stable release](http://compass-style.org/docs/ The Documentation for the [latest preview release](http://beta.compass-style.org/) -0.11.beta.5 (UNRELEASED) +0.11.beta.6 (3/27/2011) +------------------------ +* Added opera prefix support for linear and radial gradients. + +0.11.beta.5 (03/27/2011) ------------------------ ### Compass Sprites diff --git a/doc-src/content/reference/compass/helpers.haml b/doc-src/content/reference/compass/helpers.haml index 340e1f45..3a8846ff 100644 --- a/doc-src/content/reference/compass/helpers.haml +++ b/doc-src/content/reference/compass/helpers.haml @@ -24,6 +24,7 @@ layout: core * [append-selector()](/reference/compass/helpers/selectors/#append-selector) * [color-stops()](/reference/compass/helpers/color-stops/) * [cos()](/reference/compass/helpers/trig/#cos) + * [css2-fallback()](/reference/compass/helpers/cross-browser/#css2-fallback) * [elements-of-type()](/reference/compass/helpers/display/) * [enumerate()](/reference/compass/helpers/selectors/#enumerate) * [font-files()](/reference/compass/helpers/font-files/) diff --git a/doc-src/content/reference/compass/helpers/cross-browser.haml b/doc-src/content/reference/compass/helpers/cross-browser.haml index f8097bd7..32396476 100644 --- a/doc-src/content/reference/compass/helpers/cross-browser.haml +++ b/doc-src/content/reference/compass/helpers/cross-browser.haml @@ -112,3 +112,14 @@ documented_functions: It is a kind of hack to sanitize the output of experimental code into a form that can be parsed by a css2.1 compliant parser. Usually this results in causing some functions to be omitted. +#css2-fallback.helper + %h3 + %a(href="#css2-fallback") + css2-fallback($value, $css2-value) + .details + %p + This function returns a value that is normally $value, + but is $css2-value when passed through the -css2() + helper function. Many of the compass css3 mixins will create a css2 fallback + value if the arguments have a css2 representation (gradients have a null css2 + representation). diff --git a/lib/compass/sass_extensions/functions/cross_browser_support.rb b/lib/compass/sass_extensions/functions/cross_browser_support.rb index 92bab46e..beb2356d 100644 --- a/lib/compass/sass_extensions/functions/cross_browser_support.rb +++ b/lib/compass/sass_extensions/functions/cross_browser_support.rb @@ -1,4 +1,31 @@ module Compass::SassExtensions::Functions::CrossBrowserSupport + + class CSS2FallbackValue < Sass::Script::Literal + attr_accessor :value, :css2_value + def children + [value, css2_value] + end + def initialize(value, css2_value) + self.value = value + self.css2_value = css2_value + end + def inspect + to_s + end + def to_s(options = self.options) + value.to_s(options) + end + def supports?(aspect) + aspect == "css2" + end + def has_aspect? + true + end + def to_css2(options = self.options) + css2_value + end + end + # Check if any of the arguments passed require a vendor prefix. def prefixed(prefix, *args) aspect = prefix.value.sub(/^-/,"") @@ -36,4 +63,8 @@ module Compass::SassExtensions::Functions::CrossBrowserSupport end end + def css2_fallback(value, css2_value) + CSS2FallbackValue.new(value, css2_value) + end + end diff --git a/test/sass_extensions_test.rb b/test/sass_extensions_test.rb index cbd75f8a..569d49f0 100644 --- a/test/sass_extensions_test.rb +++ b/test/sass_extensions_test.rb @@ -89,6 +89,12 @@ class SassExtensionsTest < Test::Unit::TestCase assert_equal "true", evaluate("blank(-compass-space-list(' '))") end + def test_css2_fallback + assert_equal "css3", evaluate("css2-fallback(css3, css2)") + assert_equal "css2", evaluate("-css2(css2-fallback(css3, css2))") + assert_equal "true", evaluate("prefixed(-css2, css2-fallback(css3, css2))") + end + protected def evaluate(value) Sass::Script::Parser.parse(value, 0, 0).perform(Sass::Environment.new).to_s