123456789_123456789_123456789_123456789_123456789_

Class: Capybara::Queries::AncestorQuery Private

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Capybara::Queries::SelectorQuery
Defined in: lib/capybara/queries/ancestor_query.rb

Constant Summary

BaseQuery - Inherited

COUNT_KEYS

SelectorQuery - Inherited

SPATIAL_KEYS, VALID_KEYS, VALID_MATCH

Class Method Summary

SelectorQuery - Inherited

BaseQuery - Inherited

Instance Attribute Summary

Instance Method Summary

Constructor Details

This class inherits a constructor from Capybara::Queries::SelectorQuery

Instance Method Details

#description(applied = false)

[ GitHub ]

  
# File 'lib/capybara/queries/ancestor_query.rb', line 20

def description(applied = false) # rubocop:disable Style/OptionalBooleanParameter
  child_query = @child_node&.instance_variable_get(:@query)
  desc = super
  desc += " that is an ancestor of #{child_query.description}" if child_query
  desc
end

#resolve_for(node, exact = nil)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/capybara/queries/ancestor_query.rb', line 7

def resolve_for(node, exact = nil)
  @child_node = node

  node.synchronize do
    scope = node.respond_to?(:session) ? node.session.current_scope : node.find(:xpath, '/*')
    match_results = super(scope, exact)
    ancestors = node.find_xpath(XPath.ancestor.to_s)
                    .map(&method(:to_element))
                    .select { |el| match_results.include?(el) }
    Capybara::Result.new(ordered_results(ancestors), self)
  end
end