if (left.unused || right.unused)
continue;
+ if (hasInherits(right))
+ continue;
+
if (!left.shorthand && right.shorthand && isComponentOf(right, left)) {
// maybe `left` can be overridden by `right` which is a shorthand?
if (!right.important && left.important)
overrideShorthand(left, right);
left.dirty = true;
+ } else if (left.shorthand && right.shorthand && isComponentOf(left, right)) {
+ // border is a shorthand but any of its components is a shorthand too
+
+ if (!left.important && right.important)
+ continue;
+
+ if (left.important && !right.important) {
+ right.unused = true;
+ continue;
+ }
+
+ var rightRestored = compactable[right.name].restore(right, compactable);
+ if (rightRestored.length > 1)
+ continue;
+
+ component = left.components.filter(nameMatchFilter(right))[0];
+ override(component, right);
+ right.dirty = true;
}
}
}
}
}
})
+ .addBatch({
+ 'border': {
+ 'topic': 'a{border:1px solid red;border-style:dotted}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['border', false , false], ['1px'], ['dotted'], ['red']]
+ ]);
+ }
+ },
+ 'border - multivalue righthand': {
+ 'topic': 'a{border:1px solid red;border-style:dotted solid}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['border', false , false], ['1px'], ['solid'], ['red']],
+ [['border-style', false , false], ['dotted'], ['solid']]
+ ]);
+ }
+ },
+ 'border - important righthand': {
+ 'topic': 'a{border:1px solid red;border-style:dotted!important}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['border', false , false], ['1px'], ['solid'], ['red']],
+ [['border-style', true , false], ['dotted']]
+ ]);
+ }
+ },
+ 'border - important lefthand': {
+ 'topic': 'a{border:1px solid red!important;border-style:dotted}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['border', true , false], ['1px'], ['solid'], ['red']]
+ ]);
+ }
+ },
+ 'border - both important': {
+ 'topic': 'a{border:1px solid red!important;border-style:dotted!important}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['border', true , false], ['1px'], ['dotted'], ['red']]
+ ]);
+ }
+ }
+ })
.addBatch({
'shorthand then longhand multiplex': {
'topic': 'p{background:top left;background-repeat:no-repeat,no-repeat}',