1var compactable = require('../compactable'); 2var InvalidPropertyError = require('../invalid-property-error'); 3 4function populateComponents(properties, validator, warnings) { 5 var component; 6 var j, m; 7 8 for (var i = properties.length - 1; i >= 0; i--) { 9 var property = properties[i]; 10 var descriptor = compactable[property.name]; 11 12 if (descriptor && descriptor.shorthand) { 13 property.shorthand = true; 14 property.dirty = true; 15 16 try { 17 property.components = descriptor.breakUp(property, compactable, validator); 18 19 if (descriptor.shorthandComponents) { 20 for (j = 0, m = property.components.length; j < m; j++) { 21 component = property.components[j]; 22 component.components = compactable[component.name].breakUp(component, compactable, validator); 23 } 24 } 25 } catch (e) { 26 if (e instanceof InvalidPropertyError) { 27 property.components = []; // this will set property.unused to true below 28 warnings.push(e.message); 29 } else { 30 throw e; 31 } 32 } 33 34 if (property.components.length > 0) 35 property.multiplex = property.components[0].multiplex; 36 else 37 property.unused = true; 38 } 39 } 40} 41 42module.exports = populateComponents; 43