Class: Puppeteer::Bidi::QueryHandler::SelectorAnalysis Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/bidi/query_handler.rb,
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(selector) ⇒ SelectorAnalysis

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.

Returns a new instance of SelectorAnalysis.

Parameters:

  • selector (Object)


37
38
39
# File 'lib/puppeteer/bidi/query_handler.rb', line 37

def initialize(selector)
  @selector = selector
end

Instance Attribute Details

#selectorObject (readonly)

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.

Returns:

  • (Object)


35
36
37
# File 'lib/puppeteer/bidi/query_handler.rb', line 35

def selector
  @selector
end

Instance Method Details

#pseudo_class_present?Boolean

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.

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/puppeteer/bidi/query_handler.rb', line 47

def pseudo_class_present?
  in_string = nil
  escape = false
  bracket_depth = 0

  selector.each_char.with_index do |char, index|
    if escape
      escape = false
      next
    end

    if in_string
      if char == '\\'
        escape = true
      elsif char == in_string
        in_string = nil
      end
      next
    end

    case char
    when '"', "'"
      in_string = char
    when '['
      bracket_depth += 1
    when ']'
      bracket_depth -= 1 if bracket_depth.positive?
    when '\\'
      escape = true
    when ':'
      next_char = selector[index + 1]
      next if next_char == ':'
      return true if bracket_depth.zero?
    end
  end

  false
end

#requires_raf_polling?Boolean

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.

Returns:

  • (Boolean)


41
42
43
# File 'lib/puppeteer/bidi/query_handler.rb', line 41

def requires_raf_polling?
  pseudo_class_present?
end