[CSS3] if a root relative url is passed to image-url, still find the file and do the normal processing.

This commit is contained in:
Chris Eppstein 2010-07-24 01:34:14 -07:00
parent e6c418062b
commit 06ab3d4b41
5 changed files with 51 additions and 2 deletions

View File

@ -36,8 +36,12 @@ module Compass::SassExtensions::Functions::Urls
def image_url(path)
path = path.value # get to the string value of the literal.
if path =~ %r{^#{Regexp.escape(Compass.configuration.http_images_path)}/(.*)}
# Treat root relative urls (without a protocol) like normal if they start with
# the images path.
path = $1
elsif absolute_path?(path)
# Short curcuit if they have provided an absolute url.
if absolute_path?(path)
return Sass::Script::String.new("url(#{path})")
end

View File

@ -0,0 +1,23 @@
.simple {
-webkit-border-radius: 4px 4px;
-moz-border-radius: 4px / 4px;
-o-border-radius: 4px / 4px;
-ms-border-radius: 4px / 4px;
-khtml-border-radius: 4px / 4px;
border-radius: 4px / 4px; }
.compound {
-webkit-border-radius: 2px 3px;
-moz-border-radius: 2px 5px / 3px 6px;
-o-border-radius: 2px 5px / 3px 6px;
-ms-border-radius: 2px 5px / 3px 6px;
-khtml-border-radius: 2px 5px / 3px 6px;
border-radius: 2px 5px / 3px 6px; }
.crazy {
-webkit-border-radius: 1px 2px;
-moz-border-radius: 1px 3px 5px 7px / 2px 4px 6px 8px;
-o-border-radius: 1px 3px 5px 7px / 2px 4px 6px 8px;
-ms-border-radius: 1px 3px 5px 7px / 2px 4px 6px 8px;
-khtml-border-radius: 1px 3px 5px 7px / 2px 4px 6px 8px;
border-radius: 1px 3px 5px 7px / 2px 4px 6px 8px; }

View File

@ -0,0 +1,8 @@
.relative {
background-image: url('/images/4x6.png?busted=true'); }
.root-relative {
background-image: url('/images/4x6.png?busted=true'); }
.absolute {
background-image: url(http://example.com/images/4x6.png); }

View File

@ -0,0 +1,5 @@
@import "compass/css3/border-radius";
.simple { @include border-radius(4px, 4px); }
.compound { @include border-radius(2px 5px, 3px 6px); }
.crazy { @include border-radius(1px 3px 5px 7px, 2px 4px 6px 8px)}

View File

@ -0,0 +1,9 @@
.relative {
background-image: image-url("4x6.png");
}
.root-relative {
background-image: image-url("/images/4x6.png");
}
.absolute {
background-image: image-url("http://example.com/images/4x6.png");
}