From d6f22a49494906b974f7667caba41a85b9c1a05d Mon Sep 17 00:00:00 2001 From: Jonah Schulte Date: Thu, 18 Sep 2014 15:25:56 -0400 Subject: [PATCH 01/14] Add browser prefix support. --- lib/compass/_functions.scss | 1 + lib/compass/functions/_browser-prefix.scss | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 lib/compass/functions/_browser-prefix.scss diff --git a/lib/compass/_functions.scss b/lib/compass/_functions.scss index e57e52f..3d5f515 100644 --- a/lib/compass/_functions.scss +++ b/lib/compass/_functions.scss @@ -1 +1,2 @@ @import "functions/lists"; +@import "functions/browser-prefix"; diff --git a/lib/compass/functions/_browser-prefix.scss b/lib/compass/functions/_browser-prefix.scss new file mode 100644 index 0000000..e71291d --- /dev/null +++ b/lib/compass/functions/_browser-prefix.scss @@ -0,0 +1,27 @@ +@function prefix($prefix, $property) { + @return #{$prefix}-#{$property}; +} + +@function -svg($property) { + @return prefix('-svg', $property); +} + +@function -owg($property) { + @return prefix('-owg', $property); +} + +@function -webkit($property) { + @return prefix('-webkit', $property); +} + +@function -moz($property) { + @return prefix('-moz', $property); +} + +@function -o($property) { + @return prefix('-o', $property); +} + +@function -pie($property) { + @return prefix('-pie', $property); +} From 2ad14b4f0a75b70d7ee3dc57a8dcab584a7e50f9 Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Thu, 18 Sep 2014 16:53:05 -0400 Subject: [PATCH 02/14] Renamed browser-prefix to cross_browser_support. --- lib/compass/_functions.scss | 2 +- .../{_browser-prefix.scss => _cross_browser_support.scss} | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) rename lib/compass/functions/{_browser-prefix.scss => _cross_browser_support.scss} (70%) diff --git a/lib/compass/_functions.scss b/lib/compass/_functions.scss index 3d5f515..b95c9f0 100644 --- a/lib/compass/_functions.scss +++ b/lib/compass/_functions.scss @@ -1,2 +1,2 @@ @import "functions/lists"; -@import "functions/browser-prefix"; +@import "functions/cross_browser_support"; diff --git a/lib/compass/functions/_browser-prefix.scss b/lib/compass/functions/_cross_browser_support.scss similarity index 70% rename from lib/compass/functions/_browser-prefix.scss rename to lib/compass/functions/_cross_browser_support.scss index e71291d..e5ea276 100644 --- a/lib/compass/functions/_browser-prefix.scss +++ b/lib/compass/functions/_cross_browser_support.scss @@ -1,3 +1,8 @@ +// +// A partial implementation of the Ruby cross browser support functions from Compass: +// https://github.com/Compass/compass/blob/stable/lib/compass/sass_extensions/functions/cross_browser_support.rb +// + @function prefix($prefix, $property) { @return #{$prefix}-#{$property}; } From 7785c0f5602cbe9d098ccbb6c4deb35fae1c0c15 Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Fri, 19 Sep 2014 14:00:03 -0400 Subject: [PATCH 03/14] Added failing test for prefix functions taking multiple properties. --- test/functionsSpec.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/functionsSpec.js b/test/functionsSpec.js index 7a26c68..6e2bc03 100644 --- a/test/functionsSpec.js +++ b/test/functionsSpec.js @@ -21,7 +21,7 @@ var property = function(prop) { return 'a{b:'+prop+';}'; } -describe("Functions", function () { +describe("List Functions", function () { // This is verifying a function that's part of libsass that Compass also provided. it("should compact a list with false values", function (done) { @@ -67,3 +67,21 @@ describe("Functions", function () { }); }); + +describe("Cross Browser Functions", function () { + + it("should prefix a property", function(done) { + render(property('prefix(-webkit, x)'), function(output, err) { + expect(output).toBe(property('-webkit-x')); + done(); + }); + }); + + it("should prefix a list of properties", function(done) { + render(property('prefix(-webkit, x, y, z)'), function(output, err) { + expect(output).toBe(property('-webkit-x, -webkit-y, -webkit-z')); + done(); + }); + }); + +}); From a90bd9b5c6413f65652e744e2866b97c8422522e Mon Sep 17 00:00:00 2001 From: Jonah Schulte Date: Fri, 19 Sep 2014 15:36:21 -0400 Subject: [PATCH 04/14] Add necessary url around image path. --- lib/compass/typography/text/_replacement.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compass/typography/text/_replacement.scss b/lib/compass/typography/text/_replacement.scss index 703571b..35e4e50 100644 --- a/lib/compass/typography/text/_replacement.scss +++ b/lib/compass/typography/text/_replacement.scss @@ -18,7 +18,7 @@ $hide-text-direction: left !default; @include hide-text; background: { @if is-url($img) { - image: $img; + image: url($img); } @else { image: image-url($img); } From d7d7283ef90a369acea2f468513c5cf23f17fadd Mon Sep 17 00:00:00 2001 From: Jonah Schulte Date: Fri, 19 Sep 2014 16:28:44 -0400 Subject: [PATCH 05/14] Expand prefix function to fix 'Cross Browser Functions should prefix a list of properties' case. --- .../functions/_cross_browser_support.scss | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/compass/functions/_cross_browser_support.scss b/lib/compass/functions/_cross_browser_support.scss index e5ea276..7a0ce67 100644 --- a/lib/compass/functions/_cross_browser_support.scss +++ b/lib/compass/functions/_cross_browser_support.scss @@ -3,8 +3,22 @@ // https://github.com/Compass/compass/blob/stable/lib/compass/sass_extensions/functions/cross_browser_support.rb // -@function prefix($prefix, $property) { - @return #{$prefix}-#{$property}; +@function prefix($prefix, $property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { + $properties: $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9; + $props: false; + @each $item in $properties { + @if $item == null {} + @else { + $item: #{$prefix}-#{$item}; + @if $props { + $props: $props, $item; + } + @else { + $props: $item; + } + } + } + @return $props; } @function -svg($property) { From 10612bb3747236ad0a1873fc16afa2e43015928c Mon Sep 17 00:00:00 2001 From: Jonah Schulte Date: Fri, 19 Sep 2014 16:31:57 -0400 Subject: [PATCH 06/14] Remove spaces from expect for 'Cross Browser Functions should prefix a list of properties' so test passes, and to match expected output of other tests. --- test/functionsSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functionsSpec.js b/test/functionsSpec.js index 6e2bc03..7fadb69 100644 --- a/test/functionsSpec.js +++ b/test/functionsSpec.js @@ -79,7 +79,7 @@ describe("Cross Browser Functions", function () { it("should prefix a list of properties", function(done) { render(property('prefix(-webkit, x, y, z)'), function(output, err) { - expect(output).toBe(property('-webkit-x, -webkit-y, -webkit-z')); + expect(output).toBe(property('-webkit-x,-webkit-y,-webkit-z')); done(); }); }); From 386dfd7767ca10ff49bfd52934b8a7e0b0aeb6ae Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Mon, 22 Sep 2014 09:08:39 -0400 Subject: [PATCH 07/14] Added more complex prefix test. --- test/functionsSpec.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/functionsSpec.js b/test/functionsSpec.js index 7fadb69..ee2ffbd 100644 --- a/test/functionsSpec.js +++ b/test/functionsSpec.js @@ -84,4 +84,11 @@ describe("Cross Browser Functions", function () { }); }); + it("should prefix a list of complex properties", function(done) { + render(property('prefix(-webkit, linear-gradient(-45deg, rgb(0,0,0) 25%, transparent 75%, transparent), linear-gradient(-45deg, #000 25%, transparent 75%, transparent))'), function(output, err) { + expect(output).toBe(property('-webkit-linear-gradient(-45deg, #000000 25%, transparent 75%, transparent),-webkit-linear-gradient(-45deg, #000 25%, transparent 75%, transparent)')); + done(); + }); + }); + }); From aec138051b963ffd23f6a3134afbdff5998c576f Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Mon, 22 Sep 2014 11:13:24 -0400 Subject: [PATCH 08/14] Added support for multiple backgrounds. --- .../functions/_cross_browser_support.scss | 39 +++++++++----- test/css3/imagesSpec.js | 20 +++++++ test/functionsSpec.js | 52 +++++++++++-------- test/helper/property.js | 3 ++ test/helper/render.js | 19 +++++++ test/helper/ruleset.js | 3 ++ 6 files changed, 101 insertions(+), 35 deletions(-) create mode 100644 test/css3/imagesSpec.js create mode 100644 test/helper/property.js create mode 100644 test/helper/render.js create mode 100644 test/helper/ruleset.js diff --git a/lib/compass/functions/_cross_browser_support.scss b/lib/compass/functions/_cross_browser_support.scss index 7a0ce67..a03e57f 100644 --- a/lib/compass/functions/_cross_browser_support.scss +++ b/lib/compass/functions/_cross_browser_support.scss @@ -3,8 +3,21 @@ // https://github.com/Compass/compass/blob/stable/lib/compass/sass_extensions/functions/cross_browser_support.rb // +@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; +} + @function prefix($prefix, $property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { - $properties: $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9; + // Support for polymorphism. + @if length($property1) > 1 and $property2 == null { + // Passing a single array of properties. + $properties: $property1; + } @else { + // Passing multiple properties. + $properties: $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9; + } + $props: false; @each $item in $properties { @if $item == null {} @@ -21,26 +34,26 @@ @return $props; } -@function -svg($property) { - @return prefix('-svg', $property); +@function -svg($property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { + @return prefix('-svg', $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9); } -@function -owg($property) { - @return prefix('-owg', $property); +@function -owg($property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { + @return prefix('-owg', $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9); } -@function -webkit($property) { - @return prefix('-webkit', $property); +@function -webkit($property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { + @return prefix('-webkit', $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9); } -@function -moz($property) { - @return prefix('-moz', $property); +@function -moz($property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { + @return prefix('-moz', $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9); } -@function -o($property) { - @return prefix('-o', $property); +@function -o($property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { + @return prefix('-o', $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9); } -@function -pie($property) { - @return prefix('-pie', $property); +@function -pie($property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { + @return prefix('-pie', $property1, $property2, $property3, $property4, $property5, $property6, $property7, $property8, $property9); } diff --git a/test/css3/imagesSpec.js b/test/css3/imagesSpec.js new file mode 100644 index 0000000..587042f --- /dev/null +++ b/test/css3/imagesSpec.js @@ -0,0 +1,20 @@ +var render = require('../helper/render'); +var ruleset = require('../helper/ruleset'); + +describe("CSS3 Images", function () { + + it("should generate a background", function (done) { + render(ruleset('@include background(ok);'), function(output, err) { + expect(output).toBe(ruleset('background:-owg-ok;background:-webkit-ok;background:-moz-ok;background:-o-ok;background:ok;')); + done(); + }, ['compass/css3/images']); + }); + + it("should generate multiple backgrounds", function (done) { + render(ruleset('$support-for-original-webkit-gradients: false; $experimental-support-for-mozilla: false; $experimental-support-for-opera: false; @include background(a, b, c);'), function(output, err) { + expect(output).toBe(ruleset('background:-webkit-a,-webkit-b,-webkit-c;background:a,b,c;')); + done(); + }, ['compass/css3/images']); + }); + +}); diff --git a/test/functionsSpec.js b/test/functionsSpec.js index ee2ffbd..6a872e4 100644 --- a/test/functionsSpec.js +++ b/test/functionsSpec.js @@ -1,25 +1,5 @@ -var sass = require('node-sass'); -var chalk = require('chalk'); - -var libDir = __dirname.replace(/test$/, 'lib'); - -var render = function(data, callback) { - sass.render({ - data: '@import "'+libDir+'/compass/functions";' + data, - outputStyle: 'compressed', - success: function(output){ - callback(output); - }, - error: function(err){ - console.log(chalk.red("Sass error:"), err); - callback('', err); - } - }); -} - -var property = function(prop) { - return 'a{b:'+prop+';}'; -} +var render = require('./helper/render'); +var property = require('./helper/property'); describe("List Functions", function () { @@ -91,4 +71,32 @@ describe("Cross Browser Functions", function () { }); }); + it("should prefix a list of properties as a single argument", function(done) { + render('$list: x, y, z;' + property('prefix(-webkit, $list)'), function(output, err) { + expect(output).toBe(property('-webkit-x,-webkit-y,-webkit-z')); + done(); + }); + }); + + it("should prefix a property with a browser function", function(done){ + render(property('-webkit(x)'), function(output, err) { + expect(output).toBe(property('-webkit-x')); + done(); + }); + }); + + it("should prefix a list of properties with a browser function", function(done) { + render(property('-webkit(x, y, z)'), function(output, err) { + expect(output).toBe(property('-webkit-x,-webkit-y,-webkit-z')); + done(); + }); + }); + + it("should prefix a list of properties with a browser function as a single argument", function(done) { + render('$list: x, y, z;' + property('-webkit($list)'), function(output, err) { + expect(output).toBe(property('-webkit-x,-webkit-y,-webkit-z')); + done(); + }); + }); + }); diff --git a/test/helper/property.js b/test/helper/property.js new file mode 100644 index 0000000..c7a988d --- /dev/null +++ b/test/helper/property.js @@ -0,0 +1,3 @@ +module.exports = function(prop) { + return 'a{b:'+prop+';}'; +} diff --git a/test/helper/render.js b/test/helper/render.js new file mode 100644 index 0000000..1f86925 --- /dev/null +++ b/test/helper/render.js @@ -0,0 +1,19 @@ +var sass = require('node-sass'); +var libDir = __dirname.replace(/test\/helper$/, 'lib'); +var chalk = require('chalk'); + +module.exports = function(data, callback, imports) { + imports = imports ? imports.map(function(i){ return '@import "'+libDir+'/'+i+'";'}) : []; + + sass.render({ + data: '@import "'+libDir+'/compass/functions";' + imports.join('') + data, + outputStyle: 'compressed', + success: function(output){ + callback(output); + }, + error: function(err){ + console.log(chalk.red("Sass error:"), err); + callback('', err); + } + }); +} \ No newline at end of file diff --git a/test/helper/ruleset.js b/test/helper/ruleset.js new file mode 100644 index 0000000..6b7dfcc --- /dev/null +++ b/test/helper/ruleset.js @@ -0,0 +1,3 @@ +module.exports = function(rules) { + return 'a{'+rules+'}'; +} \ No newline at end of file From 596ce3cab66d706073df9abce6dcb41e314b8a39 Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Mon, 22 Sep 2014 15:39:54 -0400 Subject: [PATCH 09/14] Corrected conditional in transition mixin to use not() as function. --- lib/compass/css3/_transition.scss | 2 +- test/css3/transitionSpec.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/css3/transitionSpec.js diff --git a/lib/compass/css3/_transition.scss b/lib/compass/css3/_transition.scss index 14c6e67..8573b98 100644 --- a/lib/compass/css3/_transition.scss +++ b/lib/compass/css3/_transition.scss @@ -171,7 +171,7 @@ $transitionable-prefixed-values: transform, transform-origin !default; @if length($transition) > 3 { $delay: nth($transition, 4); $has-delays: true; } // If a delay is provided without a timing function - @if is-time($timing-function) and not $delay { $delay: $timing-function; $timing-function: false; $has-delays: true; } + @if is-time($timing-function) and not($delay) { $delay: $timing-function; $timing-function: false; $has-delays: true; } // Keep a list of delays in case one is specified $delays: append($delays, if($delay, $delay, 0s)); diff --git a/test/css3/transitionSpec.js b/test/css3/transitionSpec.js new file mode 100644 index 0000000..31026df --- /dev/null +++ b/test/css3/transitionSpec.js @@ -0,0 +1,13 @@ +var render = require('../helper/render'); +var ruleset = require('../helper/ruleset'); + +describe("CSS3 Transition", function () { + + it("should generate a transition", function (done) { + render(ruleset('$experimental-support-for-mozilla: false; $experimental-support-for-opera: false; @include transition(ok 0s);'), function(output, err) { + expect(output).toBe(ruleset('-webkit-transition:ok 0s;transition:ok 0s;')); + done(); + }, ['compass/css3/transition']); + }); + +}); From 6effddf4a49575bc34158492a7201710c3f40b9d Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Tue, 23 Sep 2014 08:43:43 -0400 Subject: [PATCH 10/14] 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(); + }); + }); + }); From 04f5b84ef33152506876d853eb76f7c58676f866 Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Tue, 23 Sep 2014 13:31:44 -0400 Subject: [PATCH 11/14] Added -compass-space-list, first-value-of, color-stops. Added border-radius test. --- lib/compass/_functions.scss | 1 + lib/compass/css3/_border-radius.scss | 4 +-- .../functions/_cross_browser_support.scss | 4 ++- lib/compass/functions/_gradient_support.scss | 15 +++++++++++ lib/compass/functions/_lists.scss | 17 ++++++++++++- test/css3/borderRadiusSpec.js | 13 ++++++++++ test/css3/imagesSpec.js | 7 ++++++ test/functionsSpec.js | 25 +++++++++++++++++++ 8 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 lib/compass/functions/_gradient_support.scss create mode 100644 test/css3/borderRadiusSpec.js diff --git a/lib/compass/_functions.scss b/lib/compass/_functions.scss index b95c9f0..6441dab 100644 --- a/lib/compass/_functions.scss +++ b/lib/compass/_functions.scss @@ -1,2 +1,3 @@ @import "functions/lists"; @import "functions/cross_browser_support"; +@import "functions/gradient_support"; diff --git a/lib/compass/css3/_border-radius.scss b/lib/compass/css3/_border-radius.scss index 3bfd041..8e09c8a 100644 --- a/lib/compass/css3/_border-radius.scss +++ b/lib/compass/css3/_border-radius.scss @@ -47,7 +47,7 @@ $default-border-radius: 5px !default; not(-o), not(-ms), not(-khtml), - not official + not(official) ); @include experimental("border-radius", $radius unquote("/") $vertical-radius, -moz, @@ -76,7 +76,7 @@ $default-border-radius: 5px !default; not(-o), not(-ms), not(-khtml), - not official + not(official) ); @include experimental("border-#{$vert}-#{$horz}-radius", $radius, not(-moz), diff --git a/lib/compass/functions/_cross_browser_support.scss b/lib/compass/functions/_cross_browser_support.scss index a092309..a6c7494 100644 --- a/lib/compass/functions/_cross_browser_support.scss +++ b/lib/compass/functions/_cross_browser_support.scss @@ -31,7 +31,9 @@ @each $item in $properties { @if $item == null {} @else { - $item: #{$prefix}-#{$item}; + @if prefixed($prefix, $item) { + $item: #{$prefix}-#{$item}; + } @if $props { $props: $props, $item; } diff --git a/lib/compass/functions/_gradient_support.scss b/lib/compass/functions/_gradient_support.scss new file mode 100644 index 0000000..8d93079 --- /dev/null +++ b/lib/compass/functions/_gradient_support.scss @@ -0,0 +1,15 @@ +/* + * A partial implementation of the Ruby gradient support functions from Compass: + * https://github.com/Compass/compass/blob/v0.12.2/lib/compass/sass_extensions/functions/gradient_support.rb + */ + +@function color-stops($item1, $item2:null, $item3:null, $item4:null, $item5:null, $item6:null, $item7:null, $item8:null, $item9:null) { + $items: $item2, $item3, $item4, $item5, $item6, $item7, $item8, $item9; + $full: $item1; + @each $item in $items { + @if $item != null { + $full: $full, $item; + } + } + @return $full; +} \ No newline at end of file diff --git a/lib/compass/functions/_lists.scss b/lib/compass/functions/_lists.scss index a118e6a..fcdadd8 100644 --- a/lib/compass/functions/_lists.scss +++ b/lib/compass/functions/_lists.scss @@ -17,7 +17,18 @@ @return nth($list, $place); } -// compass_list and compass_space_list can't be implemented in sass script +// compass_list can't be implemented in sass script + +@function -compass-space-list($item1, $item2:null, $item3:null, $item4:null, $item5:null, $item6:null, $item7:null, $item8:null, $item9:null) { + $items: $item2, $item3, $item4, $item5, $item6, $item7, $item8, $item9; + $full: $item1; + @each $item in $items { + @if $item != null { + $full: $full $item; + } + } + @return $full; +} @function -compass-list-size($list) { @return length($list); @@ -51,3 +62,7 @@ } @return $full; } + +@function first-value-of($list) { + @return nth($list, 1); +} \ No newline at end of file diff --git a/test/css3/borderRadiusSpec.js b/test/css3/borderRadiusSpec.js new file mode 100644 index 0000000..897413a --- /dev/null +++ b/test/css3/borderRadiusSpec.js @@ -0,0 +1,13 @@ +var render = require('../helper/render'); +var ruleset = require('../helper/ruleset'); + +describe("CSS3 Border Radius", function () { + + it("should generate a border radius", function (done) { + render(ruleset('$experimental-support-for-mozilla: false; $experimental-support-for-opera: false; @include border-radius(0, 0);'), function(output, err) { + expect(output).toBe(ruleset('-webkit-border-radius:0 0;border-radius:0 / 0;')); + done(); + }, ['compass/css3/border-radius']); + }); + +}); diff --git a/test/css3/imagesSpec.js b/test/css3/imagesSpec.js index 587042f..3caf745 100644 --- a/test/css3/imagesSpec.js +++ b/test/css3/imagesSpec.js @@ -17,4 +17,11 @@ describe("CSS3 Images", function () { }, ['compass/css3/images']); }); + it("should generate multiple backgrounds of different types", function (done) { + render(ruleset('$support-for-original-webkit-gradients: false; $experimental-support-for-mozilla: false; $experimental-support-for-opera: false; @include background(#fff, url(1.gif), linear-gradient(white, black));'), function(output, err) { + expect(output).toBe(ruleset('background:#fff,url(1.gif),-webkit-linear-gradient(#ffffff, #000000);background:#fff,url(1.gif),linear-gradient(#ffffff, #000000);')); + done(); + }, ['compass/css3/images']); + }); + }); diff --git a/test/functionsSpec.js b/test/functionsSpec.js index 9eb7224..9e12c92 100644 --- a/test/functionsSpec.js +++ b/test/functionsSpec.js @@ -46,6 +46,20 @@ describe("List Functions", function () { }); }); + it("should get the first value of a list", function(done) { + render('$list: one, two, three, four;' + property('first-value-of($list)'), function(output, err) { + expect(output).toBe(property('one')); + done(); + }); + }); + + it("should create a space-delimited list", function(done) { + render(property('-compass-space-list(a, b, c)'), function(output, err) { + expect(output).toBe(property('a b c')); + done(); + }); + }); + }); describe("Cross Browser Functions", function () { @@ -107,3 +121,14 @@ describe("Cross Browser Functions", function () { }); }); + +describe("Gradient Functions", function () { + + it("should prefix a list with color stops", function(done) { + render(property('prefix(-webkit, linear-gradient(-45deg, color-stops(rgb(0,0,0) 25%, transparent 75%, transparent)), linear-gradient(-45deg, color-stops(#000 25%, transparent 75%, transparent)))'), function(output, err) { + expect(output).toBe(property('-webkit-linear-gradient(-45deg, #000000 25%, transparent 75%, transparent),-webkit-linear-gradient(-45deg, #000 25%, transparent 75%, transparent)')); + done(); + }); + }); + +}); \ No newline at end of file From 409ed62c956e96dca139139b2fe156778430c61c Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Fri, 26 Sep 2014 15:00:52 -0400 Subject: [PATCH 12/14] Fixed some conditions when errors as undefined. --- lib/compass/functions/_cross_browser_support.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/compass/functions/_cross_browser_support.scss b/lib/compass/functions/_cross_browser_support.scss index a6c7494..45a3b4f 100644 --- a/lib/compass/functions/_cross_browser_support.scss +++ b/lib/compass/functions/_cross_browser_support.scss @@ -18,6 +18,8 @@ } @function prefix($prefix, $property1, $property2:null, $property3:null, $property4:null, $property5:null, $property6:null, $property7:null, $property8:null, $property9:null) { + $properties: ""; + // Support for polymorphism. @if length($property1) > 1 and $property2 == null { // Passing a single array of properties. From 8eeac829485fb80b425af4ce62be6a8bead4c9a2 Mon Sep 17 00:00:00 2001 From: Scott Douglas Date: Mon, 13 Oct 2014 10:53:08 -0400 Subject: [PATCH 13/14] Adding test for default box shadow. Commas are currently being output instead of spaces. --- test/css3/boxShadowSpec.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/css3/boxShadowSpec.js diff --git a/test/css3/boxShadowSpec.js b/test/css3/boxShadowSpec.js new file mode 100644 index 0000000..fef368d --- /dev/null +++ b/test/css3/boxShadowSpec.js @@ -0,0 +1,13 @@ +var render = require('../helper/render'); +var ruleset = require('../helper/ruleset'); + +describe("CSS3 Box Shadow", function () { + + it("should generate a default box shadow", function (done) { + render(ruleset('$default-box-shadow-inset: inset; $default-box-shadow-h-offset: 23px; $default-box-shadow-v-offset: 24px; $default-box-shadow-blur: 17px; $default-box-shadow-spread: 15px; $default-box-shadow-color: #DEADBE; $experimental-support-for-mozilla: false; $experimental-support-for-opera: false; @include box-shadow;'), function(output, err) { + expect(output).toBe(ruleset('-webkit-box-shadow:inset 23px 24px 17px 15px #DEADBE;box-shadow:inset 23px 24px 17px 15px #DEADBE;')); + done(); + }, ['compass/css3/box-shadow']); + }); + +}); From dde494d65b6ff1900ad3bf1894db9426319f696e Mon Sep 17 00:00:00 2001 From: Michael Hellein Date: Mon, 13 Oct 2014 16:12:57 -0400 Subject: [PATCH 14/14] Refactored -compass-space-list to accept a single array argument. --- .../functions/_cross_browser_support.scss | 2 +- lib/compass/functions/_lists.scss | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/compass/functions/_cross_browser_support.scss b/lib/compass/functions/_cross_browser_support.scss index 45a3b4f..76c3fc2 100644 --- a/lib/compass/functions/_cross_browser_support.scss +++ b/lib/compass/functions/_cross_browser_support.scss @@ -21,7 +21,7 @@ $properties: ""; // Support for polymorphism. - @if length($property1) > 1 and $property2 == null { + @if type-of($property1) == 'list' { // Passing a single array of properties. $properties: $property1; } @else { diff --git a/lib/compass/functions/_lists.scss b/lib/compass/functions/_lists.scss index fcdadd8..d5212fe 100644 --- a/lib/compass/functions/_lists.scss +++ b/lib/compass/functions/_lists.scss @@ -20,13 +20,23 @@ // compass_list can't be implemented in sass script @function -compass-space-list($item1, $item2:null, $item3:null, $item4:null, $item5:null, $item6:null, $item7:null, $item8:null, $item9:null) { - $items: $item2, $item3, $item4, $item5, $item6, $item7, $item8, $item9; - $full: $item1; - @each $item in $items { + // Support for polymorphism. + @if type-of($item1) == 'list' { + // Passing a single array of properties. + $items: $item1; + } @else { + $items: $item1 $item2 $item3 $item4 $item5 $item6 $item7 $item8 $item9; + } + + $full: first-value-of($items); + + @for $i from 2 through length($items) { + $item: nth($items, $i); @if $item != null { $full: $full $item; - } + } } + @return $full; }