WhiteSpace.js 551 B

12345678910111213141516171819
  1. module.exports = function cleanWhitespace(node, item, list) {
  2. // remove when first or last item in sequence
  3. if (item.next === null || item.prev === null) {
  4. list.remove(item);
  5. return;
  6. }
  7. // remove when previous node is whitespace
  8. if (item.prev.data.type === 'WhiteSpace') {
  9. list.remove(item);
  10. return;
  11. }
  12. if ((this.stylesheet !== null && this.stylesheet.children === list) ||
  13. (this.block !== null && this.block.children === list)) {
  14. list.remove(item);
  15. return;
  16. }
  17. };