return true;
}
+function alwaysButIntoFunction(property1, property2, validator) {
+ var value1 = property1.value[0][0];
+ var value2 = property2.value[0][0];
+
+ var validFunction1 = validator.isValidFunction(value1);
+ var validFunction2 = validator.isValidFunction(value2);
+
+ if (validFunction1 && validFunction2) {
+ return validator.areSameFunction(value1, value2);
+ } else if (!validFunction1 && validFunction2) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
function backgroundImage(property1, property2, validator) {
// The idea here is that 'more understandable' values override 'less understandable' values, but not vice versa
// Understandability: (none | url | inherit) > (same function) > (same value)
module.exports = {
always: always,
+ alwaysButIntoFunction: alwaysButIntoFunction,
backgroundImage: backgroundImage,
border: border,
color: color,
var MULTIPLEX_SEPARATOR = ',';
function everyCombination(fn, left, right, validator) {
+ var samePositon = !left.shorthand && !right.shorthand;
var _left = shallowClone(left);
var _right = shallowClone(right);
if (left.value[i][0] == MULTIPLEX_SEPARATOR || right.value[j][0] == MULTIPLEX_SEPARATOR)
continue;
+ if (samePositon && i != j)
+ continue;
+
_left.value = [left.value[i]];
_right.value = [right.value[j]];
if (!fn(_left, _right, validator))
]);
}
},
+ 'longhand then longhand - background position as function': {
+ 'topic': 'p{background-position:-moz-calc(100% - 1em) 0;background-position:calc(100% - 1em) 0}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['background-position'], ['-moz-calc(100% - 1em)'], ['0']],
+ [['background-position'], ['calc(100% - 1em)'], ['0']]
+ ]);
+ }
+ },
+ 'longhand then longhand - background position as same function': {
+ 'topic': 'p{background-position:calc(100% - 1em) 0;background-position:calc(100% - 1em) 1em}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['background-position'], ['calc(100% - 1em)'], ['1em']]
+ ]);
+ }
+ },
+ 'longhand then longhand - background position as function by value': {
+ 'topic': 'p{background-position:calc(100% - 1em) 0;background-position:1em 1em}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['background-position'], ['1em'], ['1em']]
+ ]);
+ }
+ },
+ 'longhand then longhand - background position as value by function': {
+ 'topic': 'p{background-position:1em 0;background-position:calc(100% - 1em) 1em}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['background-position'], ['1em'], ['0']],
+ [['background-position'], ['calc(100% - 1em)'], ['1em']]
+ ]);
+ }
+ },
+ 'longhand then longhand - background size as function': {
+ 'topic': 'p{background-size:-moz-calc(100% - 1em) 0;background-size:calc(100% - 1em) 0}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['background-size'], ['-moz-calc(100% - 1em)'], ['0']],
+ [['background-size'], ['calc(100% - 1em)'], ['0']]
+ ]);
+ }
+ },
'longhand then shorthand': {
'topic': 'p{background-image:none;background:__ESCAPED_URL_CLEAN_CSS0__}',
'into': function (topic) {