// Contains the interpretation of CSS properties, as used by the property optimizer var breakUp = require('./break-up'); var canOverride = require('./can-override'); var restore = require('./restore'); // Properties to process // Extend this object in order to add support for more properties in the optimizer. // // Each key in this object represents a CSS property and should be an object. // Such an object contains properties that describe how the represented CSS property should be handled. // Possible options: // // * components: array (Only specify for shorthand properties.) // Contains the names of the granular properties this shorthand compacts. // // * canOverride: function (Default is canOverride.sameValue - meaning that they'll only be merged if they have the same value.) // Returns whether two tokens of this property can be merged with each other. // This property has no meaning for shorthands. // // * defaultValue: string // Specifies the default value of the property according to the CSS standard. // For shorthand, this is used when every component is set to its default value, therefore it should be the shortest possible default value of all the components. // // * shortestValue: string // Specifies the shortest possible value the property can possibly have. // (Falls back to defaultValue if unspecified.) // // * breakUp: function (Only specify for shorthand properties.) // Breaks the shorthand up to its components. // // * restore: function (Only specify for shorthand properties.) // Puts the shorthand together from its components. // var compactable = { 'color': { canOverride: canOverride.color, defaultValue: 'transparent', shortestValue: 'red' }, 'background': { components: [ 'background-image', 'background-position', 'background-size', 'background-repeat', 'background-attachment', 'background-origin', 'background-clip', 'background-color' ], breakUp: breakUp.multiplex(breakUp.background), defaultValue: '0 0', restore: restore.multiplex(restore.background), shortestValue: '0', shorthand: true }, 'background-clip': { canOverride: canOverride.always, defaultValue: 'border-box', shortestValue: 'border-box' }, 'background-color': { canOverride: canOverride.color, defaultValue: 'transparent', multiplexLastOnly: true, nonMergeableValue: 'none', shortestValue: 'red' }, 'background-image': { canOverride: canOverride.backgroundImage, defaultValue: 'none' }, 'background-origin': { canOverride: canOverride.always, defaultValue: 'padding-box', shortestValue: 'border-box' }, 'background-repeat': { canOverride: canOverride.always, defaultValue: ['repeat'], doubleValues: true }, 'background-position': { canOverride: canOverride.alwaysButIntoFunction, defaultValue: ['0', '0'], doubleValues: true, shortestValue: '0' }, 'background-size': { canOverride: canOverride.alwaysButIntoFunction, defaultValue: ['auto'], doubleValues: true, shortestValue: '0 0' }, 'background-attachment': { canOverride: canOverride.always, defaultValue: 'scroll' }, 'border': { breakUp: breakUp.border, canOverride: canOverride.border, components: [ 'border-width', 'border-style', 'border-color' ], defaultValue: 'none', restore: restore.withoutDefaults, shorthand: true }, 'border-color': { canOverride: canOverride.color, defaultValue: 'none', shorthand: true }, 'border-style': { canOverride: canOverride.always, defaultValue: 'none', shorthand: true }, 'border-width': { canOverride: canOverride.unit, defaultValue: 'medium', shortestValue: '0', shorthand: true }, 'list-style': { components: [ 'list-style-type', 'list-style-position', 'list-style-image' ], canOverride: canOverride.always, breakUp: breakUp.listStyle, restore: restore.withoutDefaults, defaultValue: 'outside', // can't use 'disc' because that'd override default 'decimal' for