From 06ab3d4b410da9d97ce4b7b3e7850cc7d09c32db Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sat, 24 Jul 2010 01:34:14 -0700 Subject: [PATCH] [CSS3] if a root relative url is passed to image-url, still find the file and do the normal processing. --- lib/compass/sass_extensions/functions/urls.rb | 8 +++++-- .../stylesheets/compass/css/border_radius.css | 23 +++++++++++++++++++ .../stylesheets/compass/css/images.css | 8 +++++++ .../compass/sass/border_radius.scss | 5 ++++ .../stylesheets/compass/sass/images.scss | 9 ++++++++ 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/stylesheets/compass/css/border_radius.css create mode 100644 test/fixtures/stylesheets/compass/css/images.css create mode 100644 test/fixtures/stylesheets/compass/sass/border_radius.scss create mode 100644 test/fixtures/stylesheets/compass/sass/images.scss diff --git a/lib/compass/sass_extensions/functions/urls.rb b/lib/compass/sass_extensions/functions/urls.rb index e6bb217d..624cb9f0 100644 --- a/lib/compass/sass_extensions/functions/urls.rb +++ b/lib/compass/sass_extensions/functions/urls.rb @@ -36,8 +36,12 @@ module Compass::SassExtensions::Functions::Urls def image_url(path) path = path.value # get to the string value of the literal. - # Short curcuit if they have provided an absolute url. - if absolute_path?(path) + 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. return Sass::Script::String.new("url(#{path})") end diff --git a/test/fixtures/stylesheets/compass/css/border_radius.css b/test/fixtures/stylesheets/compass/css/border_radius.css new file mode 100644 index 00000000..5eef9e03 --- /dev/null +++ b/test/fixtures/stylesheets/compass/css/border_radius.css @@ -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; } diff --git a/test/fixtures/stylesheets/compass/css/images.css b/test/fixtures/stylesheets/compass/css/images.css new file mode 100644 index 00000000..c4e97ca5 --- /dev/null +++ b/test/fixtures/stylesheets/compass/css/images.css @@ -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); } \ No newline at end of file diff --git a/test/fixtures/stylesheets/compass/sass/border_radius.scss b/test/fixtures/stylesheets/compass/sass/border_radius.scss new file mode 100644 index 00000000..685ad4cc --- /dev/null +++ b/test/fixtures/stylesheets/compass/sass/border_radius.scss @@ -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)} diff --git a/test/fixtures/stylesheets/compass/sass/images.scss b/test/fixtures/stylesheets/compass/sass/images.scss new file mode 100644 index 00000000..65d583f3 --- /dev/null +++ b/test/fixtures/stylesheets/compass/sass/images.scss @@ -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"); +} \ No newline at end of file