return result;
},
// Puts together the components by spaces and omits default values (this is the case for most shorthands)
- bySpacesOmitDefaults: function (prop, tokens, isImportant) {
+ bySpacesOmitDefaults: function (prop, tokens, isImportant, meta) {
var result = new Token(prop, '', isImportant);
// Get irrelevant tokens
continue;
}
+ if (meta && meta.partsCount && meta.position < meta.partsCount - 1 && processable[token.prop].multiValueLastOnly)
+ continue;
+
result.value += ' ' + token.value;
}
tokens[k].value = merged[i][k];
}
- var processed = assembleFunction(prop, tokens, isImportant);
+ var meta = {
+ partsCount: partsCount,
+ position: i
+ };
+ var processed = assembleFunction(prop, tokens, isImportant, meta);
mergedValues.push(processed.value);
if (!firstProcessed)
},
// Handles the cases when some or all the fine-grained properties are set to inherit
takeCareOfInherit: function (innerFunc) {
- return function (prop, tokens, isImportant) {
+ return function (prop, tokens, isImportant, meta) {
// Filter out the inheriting and non-inheriting tokens in one iteration
var inheritingTokens = [];
var nonInheritingTokens = [];
var result1 = [new Token(prop, 'inherit', isImportant)].concat(nonInheritingTokens);
// Result 2. Shorthand every non-inherit value and then have it overridden with the inheriting ones
- var result2 = [innerFunc(prop, result2Shorthandable, isImportant)].concat(inheritingTokens);
+ var result2 = [innerFunc(prop, result2Shorthandable, isImportant, meta)].concat(inheritingTokens);
// Return whichever is shorter
var dl1 = Token.getDetokenizedLength(result1);
return dl1 < dl2 ? result1 : result2;
} else {
// When none of tokens are 'inherit'
- return innerFunc(prop, tokens, isImportant);
+ return innerFunc(prop, tokens, isImportant, meta);
}
};
},
'background-color': {
canOverride: canOverride.color,
defaultValue: 'transparent',
+ multiValueLastOnly: true,
shortestValue: 'red'
},
'background-image': {
'lost background position': [
'.one{background:50% no-repeat}.one{background-image:url(/img.png)}',
'.one{background:url(/img.png) 50% no-repeat}'
+ ],
+ 'merging color with backgrounds': [
+ 'p{background:red;background-image:url(1.png),url(2.png)}',
+ 'p{background:url(1.png),url(2.png) red}'
]
}),
'viewport units': cssContext({