Module: Loofah::ScrubBehavior::Node

Included in:
HTML::Document, XML::Document
Defined in:
lib/loofah/instance_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#scrub!(scrubber) ⇒ Object



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

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