hyalite 0.3.0 → 0.3.4

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: 5df6a60774832f8c464f4068dcb1e9b41d5032d96845da36641cae82af36c05a
4
+ data.tar.gz: 18c395c9fe8555880b94c6260fa99c3f95c22176db8598f644397944b1c13d37
5
5
  SHA512:
6
- metadata.gz: 779e397173dd2e174640e4c6fe24a4f989311d9a7bcbf5dc39dc35f616c78651c696425a2ddec7326d4c99975bc6a21da5aeea6850a5766bfc01fdf3b3f0c16d
7
- data.tar.gz: a1f67a9f3a62a39ba32255fecd1d190e05bda73786a75fa1e8659da82e2c4e37db46fd892e20aa1470d02f79d0b8b37e8b1082c70a69c5a677281c107c3165aa
6
+ metadata.gz: 4746cfb7725e9b47924e7999e89b1d163a0974e6ba08260da8726696e0030642a113a442cfd6d961b87db98ad870b2800a60f1939e14d013da7932155d2a2a44
7
+ data.tar.gz: f8f3bedb133ddcda97686e6733c47a5444dee37596dd1bc24a0bb4d93ec3a7c97cad1cd98064f733471d8030d1eaa04269a9611700d68a1cf227911def4b6a5f
data/hyalite.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'opal'
22
+ spec.add_dependency 'opal', "~> 1.0"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.8"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
@@ -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
@@ -15,20 +15,20 @@ module Hyalite::DOM
15
15
  end
16
16
 
17
17
  def input_type
18
- `self.native.type`
18
+ `#@native.type`
19
19
  end
20
20
 
21
21
  def [](prop_name)
22
- `self.native[#{prop_name}]`
22
+ `#@native[#{prop_name}]`
23
23
  end
24
24
 
25
25
  def add_class(name)
26
- `self.native.classList.add(name)`
26
+ `#@native.classList.add(name)`
27
27
  self
28
28
  end
29
29
 
30
30
  def class_names
31
- Array.new(`self.native.classList`).to_a
31
+ Array.new(`#@native.classList`).to_a
32
32
  end
33
33
 
34
34
  def attributes
@@ -36,11 +36,11 @@ module Hyalite::DOM
36
36
  end
37
37
 
38
38
  def text
39
- `self.native.textContent`
39
+ `#@native.textContent`
40
40
  end
41
41
 
42
42
  def text=(text)
43
- `self.native.textContent = text`
43
+ `#@native.textContent = text`
44
44
  end
45
45
 
46
46
  def width
@@ -59,22 +59,26 @@ module Hyalite::DOM
59
59
  `#@native.clientLeft`
60
60
  end
61
61
 
62
+ def client_rect
63
+ Native(`#@native.getBoundingClientRect()`)
64
+ end
65
+
62
66
  def style(hash)
63
67
  hash.each do |key, value|
64
- `self.native.style[key] = value`
68
+ `#@native.style[key] = value`
65
69
  end
66
70
  end
67
71
 
68
72
  def add_child(child)
69
- `self.native.appendChild(child.native)`
73
+ `#@native.appendChild(child.native)`
70
74
  end
71
75
 
72
76
  def inner_html
73
- `self.native.innerHTML`
77
+ `#@native.innerHTML`
74
78
  end
75
79
 
76
80
  def inner_html=(html)
77
- `self.native.innerHTML = html`
81
+ `#@native.innerHTML = html`
78
82
  end
79
83
 
80
84
  def inner_dom=(dom)
@@ -87,7 +91,7 @@ module Hyalite::DOM
87
91
  end
88
92
 
89
93
  def to_s
90
- "<#{`self.native.tagName`} class='#{self.class_names.join(' ')}' id='#{self['id']}'/>"
94
+ "<#{`#@native.tagName`} class='#{self.class_names.join(' ')}' id='#{self['id']}' />"
91
95
  end
92
96
 
93
97
  def self.create(tag)
@@ -0,0 +1,14 @@
1
+ module Hyalite::DOM
2
+ class HtmlInput
3
+ include Native
4
+ include Element
5
+
6
+ def self.create()
7
+ $document.create_text(text)
8
+ end
9
+
10
+ def checked?
11
+ `#@native.checked`
12
+ end
13
+ end
14
+ end
@@ -27,47 +27,55 @@ module Hyalite::DOM
27
27
  end
28
28
 
29
29
  def attr(name)
30
- `self.native[name]`
30
+ `#@native[name] || #{nil}`
31
+ end
32
+
33
+ def data(name)
34
+ `#@native.dataset[#{name}] || #{nil}`
35
+ end
36
+
37
+ def insert_before(node)
38
+ `#@native.parentNode.insertBefore(#{node.native}, #@native)`
31
39
  end
32
40
 
33
41
  def node_name
34
- `self.native.tagName`
42
+ `#@native.tagName`
35
43
  end
36
44
 
37
45
  def <<(child)
38
- `self.native.appendChild(child.native)`
46
+ `#@native.appendChild(child.native)`
39
47
  end
40
48
 
41
49
  def clear
42
50
  %x(
43
- var len = self.native.childNodes.length;
51
+ var len = #@native.childNodes.length;
44
52
  for (var i = 0; i < len; i++) {
45
- self.native.childNodes[0].remove();
53
+ #@native.childNodes[0].remove();
46
54
  }
47
55
  )
48
56
  end
49
57
 
50
58
  def parent
51
- if parent = `self.native.parentNode`
59
+ if parent = `#@native.parentNode`
52
60
  Node.create(parent)
53
61
  end
54
62
  end
55
63
 
56
64
  def children
57
- Collection.new `self.native.childNodes`
65
+ Collection.new `#@native.childNodes`
58
66
  end
59
67
 
60
68
  def remove
61
- `self.native.remove()`
69
+ `#@native.remove()`
62
70
  end
63
71
 
64
72
  def next_sibling
65
- sib = `self.native.nextSibling`
73
+ sib = `#@native.nextSibling`
66
74
  Node.create(sib) if sib
67
75
  end
68
76
 
69
77
  def ==(other)
70
- `self.native === other.native`
78
+ `#@native === other.native`
71
79
  end
72
80
  end
73
81
  end
@@ -9,6 +9,10 @@ module Hyalite::DOM
9
9
  Native(`#@native.location`)
10
10
  end
11
11
 
12
+ def location=(loc)
13
+ Native(`#@native.location=loc`)
14
+ end
15
+
12
16
  def width
13
17
  `#@native.innerWidth`
14
18
  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)
data/lib/hyalite/mount.rb CHANGED
@@ -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
@@ -198,7 +198,7 @@ module Hyalite
198
198
  if index >= parent_node.children.length
199
199
  parent_node.add_child(child_node)
200
200
  else
201
- parent_node.children[index].add_previous_sibling(child_node)
201
+ parent_node.children[index].insert_before(child_node)
202
202
  end
203
203
  end
204
204
  end
@@ -1,3 +1,3 @@
1
1
  module Hyalite
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
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.4
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: 2022-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +92,7 @@ files:
92
92
  - lib/hyalite/dom/event/mouse_event_interface.rb
93
93
  - lib/hyalite/dom/event/touch_event.rb
94
94
  - lib/hyalite/dom/event_target.rb
95
+ - lib/hyalite/dom/html_input.rb
95
96
  - lib/hyalite/dom/node.rb
96
97
  - lib/hyalite/dom/text.rb
97
98
  - lib/hyalite/dom/window.rb
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  - !ruby/object:Gem::Version
144
145
  version: '0'
145
146
  requirements: []
146
- rubygems_version: 3.0.1
147
+ rubygems_version: 3.1.2
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: Virtual DOM implimentation in Ruby