From 6b884d34c3317bd845d6250e6ec41ed59df4d4bf Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Tue, 19 Apr 2011 20:31:29 -0400 Subject: [PATCH] added the ability to disable magic sprites --- Gemfile.lock | 2 +- .../compass/utilities/sprites/_base.scss | 7 ++++++- spec/sprites_spec.rb | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5551c75d..683be5e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,7 @@ GIT PATH remote: . specs: - compass (0.11.beta.7.5b9a90f) + compass (0.11.beta.7.3e013b8) chunky_png (~> 1.1.0) sass (>= 3.1.0.alpha.249) diff --git a/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss b/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss index cd77be43..bc63081b 100644 --- a/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss +++ b/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss @@ -20,12 +20,17 @@ $sprite-selectors: hover, target, active !default; // class or you can specify the `sprite-url` explicitly like this: // // background: $map no-repeat; + +$disable-magic-sprite-selectors:false !default; + @mixin sprite($map, $sprite, $dimensions: false, $offset-x: 0, $offset-y: 0) { @include sprite-background-position($map, $sprite, $offset-x, $offset-y); @if $dimensions { @include sprite-dimensions($map, $sprite); } - @include sprite-selectors($map, $sprite, $sprite); + @if not $disable-magic-sprite-selectors { + @include sprite-selectors($map, $sprite, $sprite); + } } // Include the selectors for the `$sprite` given the `$map` and the diff --git a/spec/sprites_spec.rb b/spec/sprites_spec.rb index afae08d2..2b39c8a3 100644 --- a/spec/sprites_spec.rb +++ b/spec/sprites_spec.rb @@ -517,6 +517,25 @@ describe Compass::Sprites do CSS end + it "should not render corret sprite with css selectors via magic mixin" do + css = render <<-SCSS + @import "selectors/*.png"; + a { + $disable-magic-sprite-selectors:true; + @include selectors-sprite(ten-by-ten) + } + SCSS + css.should == <<-CSS + .selectors-sprite, a { + background: url('/selectors-edfef809e2.png') no-repeat; + } + + a { + background-position: 0 0; + } + CSS + end + it "should raise error on filenames that are not valid sass syntax" do lambda do render <<-SCSS