hyalite 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cee62746243fb66ec1822aa5f86ed56c6337b9848dcc1eeb367e0d0d0cfbbf1
4
- data.tar.gz: bab11fdea1c47d9c39de6c373d9beb2c63d7569b7c5026d190f0db041ceacceb
3
+ metadata.gz: 0ad8e3484bfee29ea87d6760ec24d8a44d2feb3e265b6b108f486f20f6541fb4
4
+ data.tar.gz: 479d8f128bd334c868f2777aa9089e772011742b8c04ccc076b293e73d7cac17
5
5
  SHA512:
6
- metadata.gz: 779e397173dd2e174640e4c6fe24a4f989311d9a7bcbf5dc39dc35f616c78651c696425a2ddec7326d4c99975bc6a21da5aeea6850a5766bfc01fdf3b3f0c16d
7
- data.tar.gz: a1f67a9f3a62a39ba32255fecd1d190e05bda73786a75fa1e8659da82e2c4e37db46fd892e20aa1470d02f79d0b8b37e8b1082c70a69c5a677281c107c3165aa
6
+ metadata.gz: 735fee94be929da9fe0c6a7b1a6af2f6eb9b2c97cef04e63c94957c8eb20e9b4643056624b9d7248afaa85635472f9cfa1cf49fdb001908639a4fee10c24cb95
7
+ data.tar.gz: 956841120bcdcf20581d93a9abfcfb0c15ae34e3b137c9dd2b3c128fa2621083d96e758b34b44b49b924c01b215b512f5c65f296c9fba8ed871f6da22637234d
@@ -109,6 +109,12 @@ module Hyalite
109
109
  end
110
110
  end
111
111
 
112
+ TAGS.each do |tag|
113
+ define_method(tag) do |props, *children, &block|
114
+ @component.send(tag, props, *children, &block)
115
+ end
116
+ end
117
+
112
118
  def method_missing(method_name, *args, &block)
113
119
  if @component.respond_to?(method_name, true)
114
120
  @component.send(method_name, *args, &block)
@@ -17,6 +17,14 @@ module Hyalite::DOM
17
17
  Element.new(`self.native.item(index)`)
18
18
  end
19
19
 
20
+ def first
21
+ Element.new(`self.native.item(0)`)
22
+ end
23
+
24
+ def last
25
+ Element.new(`self.native.item(self.native.length - 1)`)
26
+ end
27
+
20
28
  def length
21
29
  `self.native.length`
22
30
  end
@@ -17,11 +17,11 @@ module Hyalite
17
17
  return
18
18
  end
19
19
 
20
- element.attributes[attribute_name]=Hyalite.escape_text_content_for_browser(value)
20
+ element.attributes[attribute_name] = Hyalite.escape_text_content_for_browser(value.to_s)
21
21
  elsif DOMProperty.is_custom_attribute(name)
22
22
  return if value.nil?
23
23
 
24
- element.attributes[name]=Hyalite.escape_text_content_for_browser(value)
24
+ element.attributes[name] = Hyalite.escape_text_content_for_browser(value.to_s)
25
25
  end
26
26
  end
27
27
 
@@ -32,7 +32,7 @@ module Hyalite
32
32
  def create_markup_for_custom_attribute(element, name, value)
33
33
  return if (!is_attribute_name_safe(name) || value == null)
34
34
 
35
- element.attributes[name]=Hyalite.escape_text_content_for_browser(value)
35
+ element.attributes[name] = Hyalite.escape_text_content_for_browser(value.to_s)
36
36
  end
37
37
 
38
38
  def is_attribute_name_safe(attribute_name)
@@ -60,7 +60,7 @@ module Hyalite
60
60
  return false unless node.element?
61
61
 
62
62
  id = node_id(node)
63
- id ? id[0] == SEPARATOR : false
63
+ id ? id[0] == Hyalite::Reconciler::SEPARATOR : false
64
64
  end
65
65
 
66
66
  def render_new_root_component(next_element, container, should_reuse_markup)
@@ -74,6 +74,40 @@ module Hyalite
74
74
  component_instance
75
75
  end
76
76
 
77
+ def unmount_component_at_node(container)
78
+ root_id = root_id(container)
79
+ component = @instances_by_root_id[root_id]
80
+ unless component
81
+ container_has_non_root_child = has_non_root_child(container)
82
+
83
+ container_id = internal_id(container)
84
+ container_id &&
85
+ container_id == InstanceHandles.root_id_from_node_id(container_id)
86
+ return false
87
+ end
88
+
89
+ Hyalite.updates.batched_updates do
90
+ unmount_component_from_node(component, container)
91
+ end
92
+
93
+ @instances_by_root_id.delete(root_id)
94
+ @containers_by_root_id.delete(root_id)
95
+ true
96
+ end
97
+
98
+ def has_non_root_child(node)
99
+ root_id = root_id(container)
100
+ root_id ? root_id != InstanceHandles.root_id_from_node_id(root_id) : false
101
+ end
102
+
103
+ def unmount_component_from_node(instance, container)
104
+ Reconciler.unmount_component(instance)
105
+
106
+ while container.children.length > 0
107
+ container.children.last.remove
108
+ end
109
+ end
110
+
77
111
  def register_component(next_component, container)
78
112
  #ReactBrowserEventEmitter.ensureScrollValueMonitoring();
79
113
 
@@ -122,7 +156,7 @@ module Hyalite
122
156
 
123
157
  def root_element_in_container(container)
124
158
  if container.document?
125
- $document
159
+ container
126
160
  else
127
161
  container.children.first
128
162
  end
@@ -1,3 +1,3 @@
1
1
  module Hyalite
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyalite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - youchan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-17 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal