Class: Nokogiri::HTML5::DocumentFragment

Inherits:
XML::DocumentFragment show all
Defined in:
lib/wasmify/rails/shims/nokogiri.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html_string) ⇒ DocumentFragment

Returns a new instance of DocumentFragment.



35
36
37
38
39
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 35

def initialize(html_string)
  @html_string = html_string
  @elements = []
  @name = html_string.match(/<(\w+)/).then { next unless _1; _1[1] }
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



33
34
35
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 33

def elements
  @elements
end

#nameObject (readonly)

Returns the value of attribute name.



33
34
35
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 33

def name
  @name
end

Instance Method Details

#childrenObject



50
51
52
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 50

def children
  []
end

#css(selector) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 41

def css(selector)
  # Return array of matching nodes
  # Must support selectors like:
  # - "a[href]" - anchor tags with href attribute
  # - "action-text-attachment" - elements by tag name
  # - Complex selectors for attachment galleries
  []
end

#deconstructObject



67
68
69
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 67

def deconstruct
  children
end

#dupObject



54
55
56
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 54

def dup
  self.class.new(@html_string)
end

#to_html(options = {}) ⇒ Object



58
59
60
61
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 58

def to_html(options = {})
  # Must respect options[:save_with] if provided
  @html_string
end