Remove parent divs only once for each `ul` element
Unified · Split
| @@ -19,8 +19,9 @@ module Docs · 18 unmodified lines | |||
| 19 | node.before(node.children).remove | 19 | node.before(node.children).remove |
| 20 | end | 20 | end |
| 21 | 21 | ||
| 22 | css('div > ul').each do |node| | 22 | parents = css('div > ul').map(&:parent).uniq |
| 23 | node.parent.before(node.parent.children).remove | 23 | parents.each do |parent| |
| 24 | parent.before(parent.children).remove | ||
| 24 | end | 25 | end |
| 25 | 26 | ||
| 26 | css('dl > dd:first-child:last-child > ul:first-child:last-child').each do |node| | 27 | css('dl > dd:first-child:last-child > ul:first-child:last-child').each do |node| |