lib/sanitize.rb in sanitize-3.1.2 vs lib/sanitize.rb in sanitize-4.0.0

- old
+ new

@@ -129,11 +129,11 @@ else path = '/html/body/node()' end frag = doc.fragment - doc.xpath(path).each {|node| frag << node } + frag << doc.xpath(path) node!(frag) to_html(frag) end @@ -235,24 +235,24 @@ end # Performs top-down traversal of the given node, operating first on the node # itself, then traversing each child (if any) in order. def traverse(node, &block) - block.call(node) + yield node child = node.child while child do prev = child.previous_sibling traverse(child, &block) - if child.parent != node + if child.parent == node + child = child.next_sibling + else # The child was unlinked or reparented, so traverse the previous node's # next sibling, or the parent's first child if there is no previous # node. child = prev ? prev.next_sibling : node.child - else - child = child.next_sibling end end end class Error < StandardError; end