From 6effddf4a49575bc34158492a7201710c3f40b9d Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Tue, 23 Sep 2014 08:43:43 -0400 Subject: [PATCH] Improved prefixed() function. --- lib/compass/functions/_cross_browser_support.scss | 13 +++++++++++-- test/functionsSpec.js | 7 +++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/compass/functions/_cross_browser_support.scss b/lib/compass/functions/_cross_browser_support.scss index a03e57f..a092309 100644 --- a/lib/compass/functions/_cross_browser_support.scss +++ b/lib/compass/functions/_cross_browser_support.scss @@ -4,8 +4,17 @@ // @function prefixed($prefix, $property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { - // This is a hack that assumes everything should be prefixed. - @return true; + $properties: $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9; + $prefixed: false; + @each $item in $properties { + @if type-of($item) == 'string' { + $prefixed: $prefixed or str-index($item, 'url') != 1 and str-index($item, 'rgb') != 1 and str-index($item, '#') != 1; + } @elseif type-of($item) == 'color' { + } @elseif $item != null { + $prefixed: true; + } + } + @return $prefixed; } @function prefix($prefix, $property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { diff --git a/test/functionsSpec.js b/test/functionsSpec.js index 6a872e4..9eb7224 100644 --- a/test/functionsSpec.js +++ b/test/functionsSpec.js @@ -99,4 +99,11 @@ describe("Cross Browser Functions", function () { }); }); + it("should not prefix numbers or colors", function(done){ + render(property('prefixed(-ok, rgb(0,0,0))')+property('prefixed(-ok, url(1.gif))')+property('prefixed(-ok, ok)'), function(output, err) { + expect(output).toBe(property('false')+property('false')+property('true')); + done(); + }); + }); + });