From: Jakub Pawlowicz Date: Sun, 29 Jun 2014 20:41:47 +0000 (+0100) Subject: Refactors addFourValueShorthand to accept hash of options. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=9902e4a612903cc5e044a257fc8517a7d52d99fb;p=clean-css.git Refactors addFourValueShorthand to accept hash of options. --- diff --git a/lib/properties/processable.js b/lib/properties/processable.js index 35fbfcca..301138f9 100644 --- a/lib/properties/processable.js +++ b/lib/properties/processable.js @@ -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',