};
breakUp.background = function (token) {
// Default values
- var result = Token.makeDefaults(['background-image', 'background-position', 'background-size', 'background-repeat', 'background-attachment', 'background-color'], token.isImportant);
+ var result = Token.makeDefaults(['background-image', 'background-position', 'background-size', 'background-repeat', 'background-attachment', 'background-clip', 'background-color'], token.isImportant);
var image = result[0];
var position = result[1];
var size = result[2];
var repeat = result[3];
var attachment = result[4];
- var color = result[5];
+ var clip = result[5];
+ var color = result[6];
var positionSet = false;
// Take care of inherit
if (token.value === 'inherit') {
// NOTE: 'inherit' is not a valid value for background-attachment so there we'll leave the default value
- color.value = image.value = repeat.value = position.value = size.value = attachment.value = 'inherit';
+ color.value = image.value = repeat.value = position.value = size.value = attachment.value = clip.value = 'inherit';
return result;
}
if (validator.isValidBackgroundAttachment(currentPart)) {
attachment.value = currentPart;
+ } else if (validator.isValidBackgroundClip(currentPart)) {
+ clip.value = currentPart;
} else if (validator.isValidBackgroundRepeat(currentPart)) {
repeat.value = currentPart;
} else if (validator.isValidBackgroundPositionPart(currentPart) || validator.isValidBackgroundSizePart(currentPart)) {
'background-size',
'background-repeat',
'background-attachment',
+ 'background-clip',
'background-color'
],
breakUp: breakUp.commaSeparatedMulitpleValues(breakUp.background),
defaultValue: '0 0',
shortestValue: '0'
},
+ 'background-clip': {
+ canOverride: canOverride.always,
+ defaultValue: 'border-box',
+ shortestValue: 'border-box'
+ },
'background-color': {
canOverride: canOverride.color,
defaultValue: 'transparent',
var backgroundAttachmentKeywords = ['inherit', 'scroll', 'fixed', 'local'];
var backgroundPositionKeywords = ['center', 'top', 'bottom', 'left', 'right'];
var backgroundSizeKeywords = ['contain', 'cover'];
+ var backgroundClipKeywords = ['border-box', 'content-box', 'padding-box'];
var listStyleTypeKeywords = ['armenian', 'circle', 'cjk-ideographic', 'decimal', 'decimal-leading-zero', 'disc', 'georgian', 'hebrew', 'hiragana', 'hiragana-iroha', 'inherit', 'katakana', 'katakana-iroha', 'lower-alpha', 'lower-greek', 'lower-latin', 'lower-roman', 'none', 'square', 'upper-alpha', 'upper-latin', 'upper-roman'];
var listStylePositionKeywords = ['inside', 'outside', 'inherit'];
var outlineStyleKeywords = ['auto', 'inherit', 'hidden', 'none', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'];
isValidBackgroundAttachment: function (s) {
return backgroundAttachmentKeywords.indexOf(s) >= 0 || validator.isValidVariable(s);
},
+ isValidBackgroundClip: function (s) {
+ return backgroundClipKeywords.indexOf(s) >= 0 || validator.isValidVariable(s);
+ },
isValidBackgroundPositionPart: function (s) {
return backgroundPositionKeywords.indexOf(s) >= 0 || cssUnitOrCalcRegex.test(s) || validator.isValidVariable(s);
},
}),
'shorthand properties': cssContext({
'shorthand background #1' : [
- 'div{background-color:#111;background-image:url(aaa);background-repeat:repeat;background-position:0 0;background-attachment:scroll;background-size:auto}',
+ 'div{background-color:#111;background-image:url(aaa);background-repeat:repeat;background-position:0 0;background-attachment:scroll;background-size:auto;background-clip:border-box}',
'div{background:url(aaa)#111}'
],
'shorthand background #2' : [
- 'div{background-color:#111;background-image:url(aaa);background-repeat:no-repeat;background-position:0 0;background-attachment:scroll;background-size:auto}',
+ 'div{background-color:#111;background-image:url(aaa);background-repeat:no-repeat;background-position:0 0;background-attachment:scroll;background-size:auto;background-clip:border-box}',
'div{background:url(aaa)no-repeat #111}'
],
'shorthand important background' : [
- 'div{background-color:#111!important;background-image:url(aaa)!important;background-repeat:repeat!important;background-position:0 0!important;background-attachment:scroll!important;background-size:auto!important}',
+ 'div{background-color:#111!important;background-image:url(aaa)!important;background-repeat:repeat!important;background-position:0 0!important;background-attachment:scroll!important;background-size:auto!important;background-clip:border-box!important}',
'div{background:url(aaa)#111!important}'
],
'shorthand important background overriding': [
'div{background-color:#111;background-image:linear-gradient(aaa);background-repeat:no-repeat;background-position:0 0;background-attachment:scroll}'
],
'a background-image with a none and a linear-gradient should result in two shorthands' : [
- 'div{background-color:#111;background-image:none;background-image:linear-gradient(aaa);background-repeat:repeat;background-position:0 0;background-attachment:scroll;background-size:auto}',
+ 'div{background-color:#111;background-image:none;background-image:linear-gradient(aaa);background-repeat:repeat;background-position:0 0;background-attachment:scroll;background-size:auto;background-clip:border-box}',
'div{background:#111;background:linear-gradient(aaa)#111}'
]
}),
'p{margin:1px;margin-right:2px!important;margin-left:4px!important}'
],
'should take into account important background-color and shorthand others into background': [
- 'p{background-color:#9fce00!important;background-image:url(hello);background-attachment:scroll;background-position:1px 2px;background-repeat:repeat-y;background-size:auto}',
+ 'p{background-color:#9fce00!important;background-image:url(hello);background-attachment:scroll;background-position:1px 2px;background-repeat:repeat-y;background-size:auto;background-clip:border-box}',
'p{background-color:#9fce00!important;background:url(hello)1px 2px repeat-y}'
],
'should take into account important outline-color and default value of outline-width': [
'p{margin:inherit}'
],
'merge multiple inherited background granular properties into one inherited shorthand': [
- 'p{background-color:inherit;background-image:inherit;background-attachment:inherit;background-position:inherit;background-repeat:inherit;;background-size:inherit}',
+ 'p{background-color:inherit;background-image:inherit;background-attachment:inherit;background-position:inherit;background-repeat:inherit;;background-size:inherit;background-clip:inherit}',
'p{background:inherit}'
],
'when shorter, optimize inherited/non-inherited background granular properties into an inherited shorthand and some non-inherited granular properties': [
- 'p{background-color:inherit;background-image:inherit;background-attachment:inherit;background-position:inherit;background-repeat:repeat-y;background-size:inherit}',
+ 'p{background-color:inherit;background-image:inherit;background-attachment:inherit;background-position:inherit;background-repeat:repeat-y;background-size:inherit;background-clip:inherit}',
'p{background:inherit;background-repeat:repeat-y}'
],
'when shorter, optimize inherited/non-inherited background granular properties into a non-inherited shorthand and some inherited granular properties': [
- 'p{background-color:#9fce00;background-image:inherit;background-attachment:scroll;background-position:1px 2px;background-repeat:repeat-y;background-size:auto}',
- 'p{background:1px 2px repeat-y #9fce00;background-image:inherit}'
+ 'p{background-color:#9fce00;background-image:inherit;background-attachment:scroll;background-position:1px 2px;background-repeat:repeat-y;background-size:auto;background-clip:inherit}',
+ 'p{background:1px 2px repeat-y #9fce00;background-image:inherit;background-clip:inherit}'
],
'put inherit to the place where it consumes the least space': [
'div{padding:0;padding-bottom:inherit;padding-right:inherit}',
'*{background:url(test.png)calc(100% - 10px)center no-repeat #fff}'
]
}),
+ 'background-clip': cssContext({
+ 'inside background shorthand': [
+ 'div{background:content-box #000}',
+ 'div{background:content-box #000}'
+ ],
+ 'into background shorthand': [
+ 'div{background:#000;background-clip:content-box}',
+ 'div{background:content-box #000}'
+ ]
+ }),
'background size with +properties.backgroundSizeMerging': cssContext({
'with background-size property': [
'a{background:none;background-image:url(1.png);background-size:28px 28px}',