processWhitespace static method

StyledElement processWhitespace(
  1. StyledElement tree
)

processWhitespace handles the removal of unnecessary whitespace from a StyledElement tree.

The criteria for determining which whitespace is replaceable is outlined at https://www.w3.org/TR/css-text-3/ and summarized at https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33

Implementation

static StyledElement processWhitespace(StyledElement tree) {
  tree = _processInternalWhitespace(tree);
  tree = _processInlineWhitespace(tree);
  tree = _processBlockWhitespace(tree);
  tree = _removeEmptyElements(tree);
  return tree;
}