Refactors addFourValueShorthand to accept hash of options.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 29 Jun 2014 20:41:47 +0000 (21:41 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 29 Jun 2014 22:27:59 +0000 (23:27 +0100)
lib/properties/processable.js

index 35fbfcc..301138f 100644 (file)
@@ -699,20 +699,21 @@ module.exports = (function () {
     }
   };
 
-  var addFourValueShorthand = function (prop, components, breakup, puttogether, canoverride, defaultValue, shortestValue) {
+  var addFourValueShorthand = function (prop, components, options) {
+    options = options || {};
     processable[prop] = {
       components: components,
-      breakUp: breakup || breakUp.fourUnits,
-      putTogether: puttogether || putTogether.takeCareOfInherit(putTogether.fourUnits),
-      defaultValue: defaultValue || '0',
-      shortestValue: shortestValue
+      breakUp: options.breakUp || breakUp.fourUnits,
+      putTogether: options.putTogether || putTogether.takeCareOfInherit(putTogether.fourUnits),
+      defaultValue: options.defaultValue || '0',
+      shortestValue: options.shortestValue
     };
     for (var i = 0; i < components.length; i++) {
       processable[components[i]] = {
-        breakUp: breakup || breakUp.fourUnits,
-        canOverride: canoverride || canOverride.unit,
-        defaultValue: defaultValue || '0',
-        shortestValue: shortestValue
+        breakUp: options.breakUp || breakUp.fourUnits,
+        canOverride: options.canOverride || canOverride.unit,
+        defaultValue: options.defaultValue || '0',
+        shortestValue: options.shortestValue
       };
     }
   };
@@ -722,49 +723,73 @@ module.exports = (function () {
     'border-top-right-radius',
     'border-bottom-right-radius',
     'border-bottom-left-radius'
-  ], breakUp.borderRadius, putTogether.borderRadius);
+  ], {
+    breakUp: breakUp.borderRadius,
+    putTogether: putTogether.borderRadius
+  });
 
   addFourValueShorthand('-moz-border-radius', [
     '-moz-border-top-left-radius',
     '-moz-border-top-right-radius',
     '-moz-border-bottom-right-radius',
     '-moz-border-bottom-left-radius'
-  ], breakUp.borderRadius, putTogether.borderRadius);
+  ], {
+    breakUp: breakUp.borderRadius,
+    putTogether: putTogether.borderRadius
+  });
 
   addFourValueShorthand('-webkit-border-radius', [
     '-webkit-border-top-left-radius',
     '-webkit-border-top-right-radius',
     '-webkit-border-bottom-right-radius',
     '-webkit-border-bottom-left-radius'
-  ], breakUp.borderRadius, putTogether.borderRadius);
+  ], {
+    breakUp: breakUp.borderRadius,
+    putTogether: putTogether.borderRadius
+  });
 
   addFourValueShorthand('-o-border-radius', [
     '-o-border-top-left-radius',
     '-o-border-top-right-radius',
     '-o-border-bottom-right-radius',
     '-o-border-bottom-left-radius'
-  ], breakUp.borderRadius, putTogether.borderRadius);
+  ], {
+    breakUp: breakUp.borderRadius,
+    putTogether: putTogether.borderRadius
+  });
 
   addFourValueShorthand('border-color', [
     'border-top-color',
     'border-right-color',
     'border-bottom-color',
     'border-left-color'
-  ], breakUp.fourBySpacesOrFunctions, null, canOverride.color, 'currentColor', 'red');
+  ], {
+    breakUp: breakUp.fourBySpacesOrFunctions,
+    canOverride: canOverride.color,
+    defaultValue: 'currentColor',
+    shortestValue: 'red'
+  });
 
   addFourValueShorthand('border-style', [
     'border-top-style',
     'border-right-style',
     'border-bottom-style',
     'border-left-style'
-  ], breakUp.fourBySpaces, null, canOverride.always, 'none');
+  ], {
+    breakUp: breakUp.fourBySpaces,
+    canOverride: canOverride.always,
+    defaultValue: 'none'
+  });
 
   addFourValueShorthand('border-width', [
     'border-top-width',
     'border-right-width',
     'border-bottom-width',
     'border-left-width'
-  ], null, null, null, 'medium', '0');
+  ], {
+    defaultValue: 'medium',
+    shortestValue: '0'
+  });
 
   addFourValueShorthand('padding', [
     'padding-top',