Class: Puppeteer::Bidi::QueryHandler Private
- Inherits:
-
Object
- Object
- Puppeteer::Bidi::QueryHandler
- Extended by:
- Singleton::SingletonClassMethods
- Includes:
- Singleton
- Defined in:
- lib/puppeteer/bidi/query_handler.rb,
sig/_supplementary.rbs,
sig/puppeteer/bidi/query_handler.rbs
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Result, SelectorAnalysis
Constant Summary collapse
- QUERY_SEPARATORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[= /].freeze
- BUILTIN_QUERY_HANDLERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'aria' => 'ARIAQueryHandler', 'pierce' => 'PierceQueryHandler', 'xpath' => 'XPathQueryHandler', 'text' => 'TextQueryHandler' }.freeze
Instance Method Summary collapse
- #analyze_default_query_handler(selector) ⇒ Object private
- #build_query_handler_result(handler, selector, handler_name) ⇒ Object private
- #builtin_query_handler_entries ⇒ Object private
- #default_query_handler_result(selector) ⇒ Object private
- #detect_handler_from_selector(name, handler, selector) ⇒ Object private
- #get_query_handler_and_selector(selector) ⇒ Object private
- #resolve_handler_constant(const_name) ⇒ Object private
Methods included from Singleton::SingletonClassMethods
Methods included from Singleton
Instance Method Details
#analyze_default_query_handler(selector) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/puppeteer/bidi/query_handler.rb', line 113 def analyze_default_query_handler(selector) analysis = SelectorAnalysis.new(selector) polling = analysis.requires_raf_polling? ? 'raf' : 'mutation' Result.new( updated_selector: selector, polling: polling, query_handler: resolve_handler_constant('CSSQueryHandler'), ) end |
#build_query_handler_result(handler, selector, handler_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
140 141 142 143 144 145 146 |
# File 'lib/puppeteer/bidi/query_handler.rb', line 140 def build_query_handler_result(handler, selector, handler_name) { updated_selector: selector, polling: (handler_name == 'aria' ? 'raf' : 'mutation'), query_handler: handler, } end |
#builtin_query_handler_entries ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 90 91 92 93 94 95 |
# File 'lib/puppeteer/bidi/query_handler.rb', line 87 def builtin_query_handler_entries Enumerator.new do |y| BUILTIN_QUERY_HANDLERS.each do |name, const_name| if (handler = resolve_handler_constant(const_name)) y << [name, handler] end end end end |
#default_query_handler_result(selector) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
124 125 126 127 128 129 130 |
# File 'lib/puppeteer/bidi/query_handler.rb', line 124 def default_query_handler_result(selector) Result.new( updated_selector: selector, polling: 'mutation', query_handler: resolve_handler_constant('CSSQueryHandler'), ) end |
#detect_handler_from_selector(name, handler, selector) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/puppeteer/bidi/query_handler.rb', line 97 def detect_handler_from_selector(name, handler, selector) QUERY_SEPARATORS.each do |separator| prefix = "#{name}#{separator}" next unless selector.start_with?(prefix) updated_selector = selector[prefix.length..] return Result.new( updated_selector: updated_selector, polling: (name == 'aria' ? 'raf' : 'mutation'), query_handler: handler, ) end nil end |
#get_query_handler_and_selector(selector) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 27 28 29 30 |
# File 'lib/puppeteer/bidi/query_handler.rb', line 22 def get_query_handler_and_selector(selector) builtin_query_handler_entries.each do |name, handler| if (result = detect_handler_from_selector(name, handler, selector)) return result end end analyze_default_query_handler(selector) end |
#resolve_handler_constant(const_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
132 133 134 135 136 137 138 |
# File 'lib/puppeteer/bidi/query_handler.rb', line 132 def resolve_handler_constant(const_name) return const_name if const_name.is_a?(Module) Puppeteer::Bidi.const_get(const_name, false) rescue NameError nil end |