// 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;
// 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;
// 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))
}
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))
// 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;