class Loofah::Scrubbers::NoOpener

scrub!(:noopener)

:noopener adds a rel=“noopener” attribute to all links

link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
Loofah.fragment(link_farmers_markup).scrub!(:noopener)
=> "ohai! <a href='http://www.myswarmysite.com/' rel="noopener">I like your blog post</a>"

Public Class Methods

new() click to toggle source
# File lib/loofah/scrubbers.rb, line 219
def initialize
  @direction = :top_down
end

Public Instance Methods

scrub(node) click to toggle source
# File lib/loofah/scrubbers.rb, line 223
def scrub(node)
  return CONTINUE unless (node.type == Nokogiri::XML::Node::ELEMENT_NODE) && (node.name == 'a')
  append_attribute(node, 'rel', 'noopener')
  return STOP
end