Module: Loofah::ScrubBehavior::Node

Included in:
HTML4::Document, HTML5::Document, XML::Document
Defined in:
lib/loofah/concerns.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#scrub!(scrubber) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/loofah/concerns.rb', line 32

def scrub!(scrubber)
  #
  #  yes. this should be three separate methods. but nokogiri decorates (or not) based on
  #  whether the module name has already been included. and since documents get decorated just
  #  like their constituent nodes, we need to jam all the logic into a single module.
  #
  scrubber = ScrubBehavior.resolve_scrubber(scrubber)
  case self
  when Nokogiri::XML::Document
    scrubber.traverse(root) if root
  when Nokogiri::XML::DocumentFragment
    children.scrub!(scrubber)
  else
    scrubber.traverse(self)
  end
  self
end