class Hyalite::TextComponent

Public Class Methods

new(text) click to toggle source
# File lib/hyalite/text_component.rb, line 7
def initialize(text)
  @text = text
end

Public Instance Methods

current_element() click to toggle source
# File lib/hyalite/text_component.rb, line 11
def current_element
  @text
end
mount_component(root_id, mount_ready, context) click to toggle source
# File lib/hyalite/text_component.rb, line 15
def mount_component(root_id, mount_ready, context)
  @root_node_id = root_id
  @native_node = $document.create_element('span').tap do |node|
    DOMPropertyOperations.set_attribute_for_id(node, root_id)
    Mount.node_id(node)
    node.text = @text
  end
end
receive_component(next_text, mount_ready) click to toggle source
# File lib/hyalite/text_component.rb, line 29
def receive_component(next_text, mount_ready)
  if next_text != @text
    @text = next_text
    node.text = @text
  end
end
unmount_component() click to toggle source
# File lib/hyalite/text_component.rb, line 24
def unmount_component
  @native_node = nil
  Mount.purge_id(@root_node_id)
end

Private Instance Methods

node() click to toggle source
# File lib/hyalite/text_component.rb, line 38
def node
  @node ||= Mount.node(@root_node_id)
end