mahirshah / css-property-parser

Validate css properties and expand shorthand css properties
MIT License
60 stars 6 forks source link

add recursive option to getShorthandComputedProperties #4

Closed chriseppstein closed 7 years ago

chriseppstein commented 7 years ago

For consistency with expandShorthandProperty, the getShorthandComputedProperties function should accept an option to recursively compute the set of properties that will be returned.

chriseppstein commented 7 years ago

I'm using this locally:

function getShorthandComputedProperties(prop: string, recurse: boolean = false): string[] {
  let props = propParser.getShorthandComputedProperties(prop);
  if (!recurse) return props;
  while (props.find(p => propParser.isShorthandProperty(p))) {
    props = props.reduce((prev, p) => {
      prev.splice(prev.length, 0, ...propParser.getShorthandComputedProperties(p));
      return prev;
    }, []);
  }
  return props;
}
mahirshah commented 7 years ago

Addressed in https://github.com/css-blocks/css-property-parser/commit/077059424654a0162ee0cf90b2abfd2d7a2c0dc9