mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Allow overriding/optimizing focused
filter in selectors
This commit is contained in:
parent
689b8cb2fb
commit
9d6153ef0b
2 changed files with 7 additions and 7 deletions
|
@ -373,6 +373,10 @@ module Capybara
|
||||||
options.key?(:style) && !custom_keys.include?(:style)
|
options.key?(:style) && !custom_keys.include?(:style)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def use_default_focused_filter?
|
||||||
|
options.key?(:focused) && !custom_keys.include?(:focused)
|
||||||
|
end
|
||||||
|
|
||||||
def use_spatial_filter?
|
def use_spatial_filter?
|
||||||
options.values_at(*SPATIAL_KEYS).compact.any?
|
options.values_at(*SPATIAL_KEYS).compact.any?
|
||||||
end
|
end
|
||||||
|
@ -498,13 +502,9 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def matches_focused_filter?(node)
|
def matches_focused_filter?(node)
|
||||||
if options.key?(:focused)
|
return true unless use_default_focused_filter?
|
||||||
node_is_focused = node == node.session.active_element
|
|
||||||
|
|
||||||
node_is_focused == options[:focused]
|
(node == node.session.active_element) == options[:focused]
|
||||||
else
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def need_to_process_classes?
|
def need_to_process_classes?
|
||||||
|
|
|
@ -14,7 +14,7 @@ require 'capybara/selector/definition'
|
||||||
# * :left_of (Element) - Match elements left of the passed element on the page
|
# * :left_of (Element) - Match elements left of the passed element on the page
|
||||||
# * :right_of (Element) - Match elements right of the passed element on the page
|
# * :right_of (Element) - Match elements right of the passed element on the page
|
||||||
# * :near (Element) - Match elements near (within 50px) the passed element on the page
|
# * :near (Element) - Match elements near (within 50px) the passed element on the page
|
||||||
# * :focused (Boolean) - Match elements with focus (requires JavaScript)
|
# * :focused (Boolean) - Match elements with focus (requires driver support)
|
||||||
#
|
#
|
||||||
# ### Built-in Selectors
|
# ### Built-in Selectors
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Reference in a new issue