]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Add more specific error to rem-calc() if a non-numeric value is passed in
authorGeoff Kimball <geoff@zurb.com>
Tue, 22 Dec 2015 19:40:18 +0000 (11:40 -0800)
committerGeoff Kimball <geoff@zurb.com>
Tue, 22 Dec 2015 19:40:18 +0000 (11:40 -0800)
scss/util/_unit.scss

index 613d9c7e20933c8d5d625a0ba8dbd21acb0ef679..2004a858d127dc4a15c5b0f3dba0c9dd14ee33f4 100644 (file)
@@ -70,11 +70,21 @@ $global-font-size: 100% !default;
 ///
 /// @returns {Number} A number in rems, calculated based on the given value and the base pixel value. rem values are passed through as is.
 @function -zf-to-rem($value, $base: null) {
+  // Check if the value is a number
+  @if type-of($value) != 'number' {
+    @warn inspect($value) + ' was passed to rem-calc(), which is not a number.';
+    @return $value;
+  }
+  
   // Calculate rem if units for $value is not rem
-  @if (unit($value) != 'rem') {
+  @if unit($value) != 'rem' {
     $value: strip-unit($value) / strip-unit($base) * 1rem;
   }
+
   // Turn 0rem into 0
-  @if ($value == 0rem) { $value: 0; }
+  @if $value == 0rem {
+    $value: 0;
+  }
+
   @return $value;
 }