Browse Source

Improved prefixed() function.

master
Michael Hellein 11 years ago
parent
commit
6effddf4a4
  1. 13
      lib/compass/functions/_cross_browser_support.scss
  2. 7
      test/functionsSpec.js

13
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) {

7
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();
});
});
});

Loading…
Cancel
Save