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.
This commit is contained in:
parent
da57adc49d
commit
f2ceec4680
@ -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/)
|
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
|
### Compass Sprites
|
||||||
|
@ -24,6 +24,7 @@ layout: core
|
|||||||
* [append-selector()](/reference/compass/helpers/selectors/#append-selector)
|
* [append-selector()](/reference/compass/helpers/selectors/#append-selector)
|
||||||
* [color-stops()](/reference/compass/helpers/color-stops/)
|
* [color-stops()](/reference/compass/helpers/color-stops/)
|
||||||
* [cos()](/reference/compass/helpers/trig/#cos)
|
* [cos()](/reference/compass/helpers/trig/#cos)
|
||||||
|
* [css2-fallback()](/reference/compass/helpers/cross-browser/#css2-fallback)
|
||||||
* [elements-of-type()](/reference/compass/helpers/display/)
|
* [elements-of-type()](/reference/compass/helpers/display/)
|
||||||
* [enumerate()](/reference/compass/helpers/selectors/#enumerate)
|
* [enumerate()](/reference/compass/helpers/selectors/#enumerate)
|
||||||
* [font-files()](/reference/compass/helpers/font-files/)
|
* [font-files()](/reference/compass/helpers/font-files/)
|
||||||
|
@ -112,3 +112,14 @@ documented_functions:
|
|||||||
It is a kind of hack to sanitize the output of experimental code
|
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.
|
into a form that can be parsed by a css2.1 compliant parser.
|
||||||
Usually this results in causing some functions to be omitted.
|
Usually this results in causing some functions to be omitted.
|
||||||
|
#css2-fallback.helper
|
||||||
|
%h3
|
||||||
|
%a(href="#css2-fallback")
|
||||||
|
css2-fallback(<span class="arg">$value</span>, <span class="arg">$css2-value</span>)
|
||||||
|
.details
|
||||||
|
%p
|
||||||
|
This function returns a value that is normally <code>$value<code>,
|
||||||
|
but is <code>$css2-value</code> when passed through the <code>-css2()</code>
|
||||||
|
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).
|
||||||
|
@ -1,4 +1,31 @@
|
|||||||
module Compass::SassExtensions::Functions::CrossBrowserSupport
|
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.
|
# Check if any of the arguments passed require a vendor prefix.
|
||||||
def prefixed(prefix, *args)
|
def prefixed(prefix, *args)
|
||||||
aspect = prefix.value.sub(/^-/,"")
|
aspect = prefix.value.sub(/^-/,"")
|
||||||
@ -36,4 +63,8 @@ module Compass::SassExtensions::Functions::CrossBrowserSupport
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def css2_fallback(value, css2_value)
|
||||||
|
CSS2FallbackValue.new(value, css2_value)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -89,6 +89,12 @@ class SassExtensionsTest < Test::Unit::TestCase
|
|||||||
assert_equal "true", evaluate("blank(-compass-space-list(' '))")
|
assert_equal "true", evaluate("blank(-compass-space-list(' '))")
|
||||||
end
|
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
|
protected
|
||||||
def evaluate(value)
|
def evaluate(value)
|
||||||
Sass::Script::Parser.parse(value, 0, 0).perform(Sass::Environment.new).to_s
|
Sass::Script::Parser.parse(value, 0, 0).perform(Sass::Environment.new).to_s
|
||||||
|
Loading…
Reference in New Issue
Block a user