Method: HTML::Selector#next_element

Defined in:
lib/action_controller/vendor/html-scanner/html/selector.rb

#next_element(element, name = nil) ⇒ Object

Return the next element after this one. Skips sibling text nodes.

With the name argument, returns the next element with that name, skipping other sibling elements.


493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/action_controller/vendor/html-scanner/html/selector.rb', line 493

def next_element(element, name = nil)
  if siblings = element.parent.children
    found = false
    siblings.each do |node|
      if node.equal?(element)
        found = true
      elsif found && node.tag?
        return node if (name.nil? || node.name == name)
      end
    end
  end
  nil
end