Class: Hyalite::TextComponent
- Includes:
- InternalComponent
- Defined in:
- lib/hyalite/text_component.rb
Instance Attribute Summary
Attributes included from InternalComponent
Instance Method Summary collapse
- #current_element ⇒ Object
-
#initialize(text) ⇒ TextComponent
constructor
A new instance of TextComponent.
- #mount_component(root_id, mount_ready, context) ⇒ Object
- #receive_component(next_text, mount_ready) ⇒ Object
- #unmount_component ⇒ Object
Methods included from InternalComponent
Constructor Details
#initialize(text) ⇒ TextComponent
Returns a new instance of TextComponent.
7 8 9 |
# File 'lib/hyalite/text_component.rb', line 7 def initialize(text) @text = text end |
Instance Method Details
#current_element ⇒ Object
11 12 13 |
# File 'lib/hyalite/text_component.rb', line 11 def current_element @text end |
#mount_component(root_id, mount_ready, context) ⇒ Object
15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
29 30 31 32 33 34 |
# 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 |