()
| 660 | sortByDepth(highlights, true); |
| 661 | |
| 662 | function flattenOnce() { |
| 663 | var again = false; |
| 664 | |
| 665 | highlights.forEach(function (hl, i) { |
| 666 | var parent = hl.parentElement, |
| 667 | parentPrev = parent.previousSibling, |
| 668 | parentNext = parent.nextSibling; |
| 669 | |
| 670 | if (self.isHighlight(parent)) { |
| 671 | |
| 672 | if (!haveSameColor(parent, hl)) { |
| 673 | |
| 674 | if (!hl.nextSibling) { |
| 675 | dom(hl).insertBefore(parentNext || parent); |
| 676 | again = true; |
| 677 | } |
| 678 | |
| 679 | if (!hl.previousSibling) { |
| 680 | dom(hl).insertAfter(parentPrev || parent); |
| 681 | again = true; |
| 682 | } |
| 683 | |
| 684 | if (!parent.hasChildNodes()) { |
| 685 | dom(parent).remove(); |
| 686 | } |
| 687 | |
| 688 | } else { |
| 689 | parent.replaceChild(hl.firstChild, hl); |
| 690 | highlights[i] = parent; |
| 691 | again = true; |
| 692 | } |
| 693 | |
| 694 | } |
| 695 | |
| 696 | }); |
| 697 | |
| 698 | return again; |
| 699 | } |
| 700 | |
| 701 | do { |
| 702 | again = flattenOnce(); |
no test coverage detected