var tokens = Token.tokenize(input);
- tokens = overrideCompactor.compactOverrides(tokens, processable, Token);
+ tokens = overrideCompactor.compactOverrides(tokens, processable, Token, compatibility);
tokens = shorthandCompactor.compactShorthands(tokens, false, processable, Token);
tokens = shorthandCompactor.compactShorthands(tokens, true, processable, Token);
return val1 === val2;
};
- var compactOverrides = function (tokens, processable, Token) {
- var result, can, token, t, i, ii, oldResult, matchingComponent;
+ var compactOverrides = function (tokens, processable, Token, compatibility) {
+ var result, can, token, t, i, ii, iiii, oldResult, matchingComponent;
// Used when searching for a component that matches token
var nameMatchFilter1 = function (x) {
if (can(matchingComponent.value, token.value)) {
// The component can override the matching component in the shorthand
+ if (compatibility) {
+ // in compatibility mode check if shorthand in not less understandable than merged-in value
+ var wouldBreakCompatibility = false;
+ for (iiii = 0; iiii < t.components.length; iiii++) {
+ var o = processable[t.components[iiii].prop];
+ can = (o && o.canOverride) || sameValue;
+
+ if (!can(o.defaultValue, t.components[iiii].value)) {
+ wouldBreakCompatibility = true;
+ break;
+ }
+ }
+
+ if (wouldBreakCompatibility) {
+ result.push(t);
+ continue;
+ }
+ }
+
if ((!token.isImportant || token.isImportant && matchingComponent.isImportant) && willResultInShorterValue(t, token)) {
// The overriding component is non-important which means we can simply include it into the shorthand
// NOTE: stuff that can't really be included, like inherit, is taken care of at the final step, not here
// token is a shorthand and is trying to override another instance of the same shorthand
// Can only override other shorthand when each of its components can override each of the other's components
- for (var iiii = 0; iiii < t.components.length; iiii++) {
+ for (iiii = 0; iiii < t.components.length; iiii++) {
can = (processable[t.components[iiii].prop] && processable[t.components[iiii].prop].canOverride) || sameValue;
if (!can(t.components[iiii].value, token.components[iiii].value)) {
result.push(t);
'a{background:red}'
]
}),
+ 'advanced in ie8 mode': cssContext({
+ 'plain component to complex shorthand': 'a{background:linear-gradient(to bottom,#000,#fff 4em) #000;background-color:#fff}',
+ 'plain component to shorthand': [
+ 'a{background:url(bg.png) #000;background-color:#fff}',
+ 'a{background:url(bg.png) #fff}'
+ ]
+ }, { compatibility: 'ie8' }),
'viewport units': cssContext({
'shorthand margin with viewport width not changed': 'div{margin:5vw}'
}),