// Functions with the same name can override each other; same values can override each other
return canOverride.sameFunctionOrValue(val1, val2);
}
- // TODO: add more
};
canOverride = Object.freeze(canOverride);
var compactedLength = Token.getDetokenizedLength(compacted);
var authenticLength = Token.getDetokenizedLength(realComponents);
- // TODO: unit test for hacked value
if (realComponents.length === processable[prop].components.length || compactedLength < authenticLength || components.some(isHackValue)) {
compacted[0].isShorthand = true;
compacted[0].components = processable[prop].breakUp(compacted[0]);
// Found an instance of a full shorthand
// NOTE: we should NOT mix together tokens that come before and after the shorthands
- if (token.isImportant === isImportant) {
+ if (token.isImportant === isImportant || (token.isImportant && !isImportant)) {
// Try to compact what we've found so far
while (compactSoFar(token.prop)) { }
// Reset
initSoFar(token.prop, token, true);
}
- // TODO: test case for shorthanding boundaries
- // TODO: what happens if the importantness of the shorthand isn't the same as isImportant parameter?
+ // TODO: when the old optimizer is removed, take care of this corner case:
+ // div{background-color:#111;background-image:url(aaa);background:linear-gradient(aaa);background-repeat:no-repeat;background-position:1px 2px;background-attachment:scroll}
+ // -> should not be shorthanded / minified at all because the result wouldn't be equivalent to the original in any browser
}
else if (processable[token.prop].componentOf) {
// Found a component of a shorthand
return s.length > 0 && s.indexOf('hsla(') === 0 && s.indexOf(')') === s.length - 1;
},
isValidNamedColor: function (s) {
- // TODO: we don't really check if it's a valid color value, but allow any letters in it
+ // We don't really check if it's a valid color value, but allow any letters in it
return s !== 'auto' && (s === 'transparent' || s === 'inherit' || /^[a-zA-Z]+$/.test(s));
},
isValidColor: function (s) {
- // http://www.w3schools.com/cssref/css_colors_legal.asp
return validator.isValidNamedColor(s) || validator.isValidHexColor(s) || validator.isValidRgbaColor(s) || validator.isValidHslaColor(s);
},
isValidUrl: function (s) {
'should NOT merge outline with inherited outline-width': [
'a{outline:0;outline-width:inherit}',
'a{outline:0;outline-width:inherit}'
+ ],
+ 'should merge list-style with list-style-type': [
+ 'li{list-style-type:disc;list-style:inside}',
+ 'li{list-style:inside}'
]
}),
'shorthand properties': cssContext({
'shorthand border-radius': [
'.t{border-top-left-radius:7px;border-bottom-right-radius:6px;border-bottom-left-radius:5px;border-top-right-radius:3px}',
'.t{border-radius:7px 3px 6px 5px}'
+ ],
+ 'shorthand list-style #1': [
+ '.t{list-style-type:circle;list-style-position:outside;list-style-image:url(aaa)}',
+ '.t{list-style:circle url(aaa)}'
+ ],
+ 'shorthand list-style #2': [
+ '.t{list-style-image:url(aaa);list-style-type:circle;list-style-position:inside}',
+ '.t{list-style:circle inside url(aaa)}'
]
}),
'care about understandability of shorthand components': cssContext({