From: Jakub Pawlowicz Date: Sun, 12 Apr 2015 13:56:44 +0000 (+0100) Subject: Simplifies value extraction in `can-override`. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d1ea9669d4650310d0122c3827046aafc32dfbd5;p=clean-css.git Simplifies value extraction in `can-override`. We now pass wrapped properties only so there's no need anymore to do an array check. --- diff --git a/lib/properties/can-override.js b/lib/properties/can-override.js index eda02741..5d0555a4 100644 --- a/lib/properties/can-override.js +++ b/lib/properties/can-override.js @@ -5,10 +5,6 @@ // The generic idea is that properties that have wider browser support are 'more understandable' // than others and that 'less understandable' values can't override more understandable ones. -function _valueOf(property) { - return Array.isArray(property.value[0]) ? property.value[0][0] : property.value[0]; -} - // Use when two tokens of the same property can always be merged function always() { return true; @@ -19,8 +15,8 @@ function backgroundImage(property1, property2, validator) { // Understandability: (none | url | inherit) > (same function) > (same value) // (none | url) - var image1 = _valueOf(property1); - var image2 = _valueOf(property2); + var image1 = property1.value[0][0]; + var image2 = property2.value[0][0]; if (image2 == 'none' || image2 == 'inherit' || validator.isValidUrl(image2)) return true; @@ -41,8 +37,8 @@ function color(property1, property2, validator) { // Understandability: (hex | named) > (rgba | hsla) > (same function name) > anything else // NOTE: at this point rgb and hsl are replaced by hex values by clean-css - var color1 = _valueOf(property1); - var color2 = _valueOf(property2); + var color1 = property1.value[0][0]; + var color2 = property2.value[0][0]; // (hex | named) if (validator.isValidNamedColor(color2) || validator.isValidHexColor(color2)) @@ -61,22 +57,22 @@ function color(property1, property2, validator) { } function twoOptionalFunctions(property1, property2, validator) { - var value1 = _valueOf(property1); - var value2 = _valueOf(property2); + var value1 = property1.value[0][0]; + var value2 = property2.value[0][0]; return !(validator.isValidFunction(value1) ^ validator.isValidFunction(value2)); } function sameValue(property1, property2) { - var value1 = _valueOf(property1); - var value2 = _valueOf(property2); + var value1 = property1.value[0][0]; + var value2 = property2.value[0][0]; return value1 === value2; } function sameFunctionOrValue(property1, property2, validator) { - var value1 = _valueOf(property1); - var value2 = _valueOf(property2); + var value1 = property1.value[0][0]; + var value2 = property2.value[0][0]; // Functions with the same name can override each other if (validator.areSameFunction(value1, value2)) @@ -92,8 +88,8 @@ function unit(property1, property2, validator) { // NOTE: there is no point in having different vendor-specific functions override each other or standard functions, // or having standard functions override vendor-specific functions, but standard functions can override each other // NOTE: vendor-specific property values are not taken into consideration here at the moment - var value1 = _valueOf(property1); - var value2 = _valueOf(property2); + var value1 = property1.value[0][0]; + var value2 = property2.value[0][0]; if (validator.isValidAndCompatibleUnitWithoutFunction(value1) && !validator.isValidAndCompatibleUnitWithoutFunction(value2)) return false;