Class: Hyalite::DOMComponent
Instance Attribute Summary collapse
#mount_index
Instance Method Summary
collapse
#recieve_component
clear_queue, insert_child_at, #instantiate_children, markup_queue, #mount_children, #move_child, process_children_updates, process_queue, process_updates, #remove_child, #unmount_child, #unmount_children, #update_children, update_depth, update_depth=, update_queue, #update_text_content, wrap_update
Constructor Details
Returns a new instance of DOMComponent.
13
14
15
16
17
|
# File 'lib/hyalite/dom_component.rb', line 13
def initialize(element)
@element = element
@tag = @element.type.downcase
@input_wrapper = InputWrapper.new(self)
end
|
Instance Attribute Details
#root_node_id ⇒ Object
Returns the value of attribute root_node_id.
11
12
13
|
# File 'lib/hyalite/dom_component.rb', line 11
def root_node_id
@root_node_id
end
|
Instance Method Details
#current_element ⇒ Object
19
20
21
|
# File 'lib/hyalite/dom_component.rb', line 19
def current_element
@element
end
|
#mount_component(root_id, mount_ready, context) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/hyalite/dom_component.rb', line 23
def mount_component(root_id, mount_ready, context)
return if @tag == "noscript"
@root_node_id = root_id
props = current_element.props
case @tag
when 'input'
@input_wrapper.mount_wrapper
props = @input_wrapper.native_props
end
markup = create_open_tag_markup_and_put_listeners(mount_ready, @element.props)
create_content_markup(mount_ready, markup, context)
end
|
#public_instance ⇒ Object
125
126
127
|
# File 'lib/hyalite/dom_component.rb', line 125
def public_instance
native_node
end
|
#receive_component(next_element, mount_ready, context) ⇒ Object
82
83
84
85
86
|
# File 'lib/hyalite/dom_component.rb', line 82
def receive_component(next_element, mount_ready, context)
prev_element = @element
@element = next_element
update_component(mount_ready, prev_element, next_element, context);
end
|
129
130
131
132
133
134
135
|
# File 'lib/hyalite/dom_component.rb', line 129
def to_s
{
tag: @tag,
root_node_id: root_node_id,
rendered_children: @rendered_children,
}.to_s
end
|
#unmount_component ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/hyalite/dom_component.rb', line 57
def unmount_component
case @tag
when 'input'
@input_wrapper.unmount_wrapper
end
unmount_children
BrowserEvent.delete_all_listeners(@root_node_id)
Mount.purge_id(@root_node_id)
@root_node_id = nil
if @node_with_legacy_properties
node = @node_with_legacy_properties
node.internal_component = nil
@node_with_legacy_properties = nil
end
end
|
#update_component(mount_ready, prev_element, next_element, context) ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/hyalite/dom_component.rb', line 88
def update_component(mount_ready, prev_element, next_element, context)
last_props = prev_element.props
next_props = @element.props
case @tag
when 'input'
@input_wrapper.update_wrapper
last_props = @input_wrapper.native_props(last_props)
end
update_dom_properties(last_props, next_props, mount_ready)
update_dom_children(last_props, next_props, mount_ready, context)
if @tag == 'select'
mount_ready.enqueue { post_update_select_wrapper }
end
end
|