Permalink
Browse files

Fix now walking full DOM in change_hrefs.

  • Loading branch information...
1 parent c301a88 commit 5f3567eac26b516982261e38856fd026b68e87bd @orangemug orangemug committed Feb 8, 2012
Showing with 3 additions and 2 deletions.
  1. +2 −1 lib/epub/dom.rb
  2. +1 −1 lib/epub/item/html.rb
View
@@ -14,7 +14,8 @@ module DOM
NOTATION_NODE = 12
def self.walk(dom, &block)
- yield(dom)
+ yield(dom) if dom.is_a?(Nokogiri::XML::Element)
+
for node in dom.children
walk(node, &block) if node.type == ELEMENT_NODE
end
View
@@ -85,7 +85,7 @@ def remove_scripts(html)
#
# @param [Nokogiri::XML] html document DOM
def change_hrefs(html)
- DOM.walk(html.children.first) do |node|
+ DOM.walk(html) do |node|
for attr_name in %w{href src}
attr_obj = node.attributes[attr_name]

0 comments on commit 5f3567e

Please sign in to comment.