hyalite 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/.travis.yml +6 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +7 -12
- data/Rakefile +2 -2
- data/client/hyalite.rb +3 -3
- data/client/hyalite/component.rb +0 -4
- data/client/hyalite/composite_component.rb +2 -7
- data/client/hyalite/dom.rb +17 -0
- data/client/hyalite/dom/body.rb +6 -0
- data/client/hyalite/dom/collection.rb +24 -0
- data/client/hyalite/dom/document.rb +41 -0
- data/client/hyalite/dom/element.rb +101 -0
- data/client/hyalite/dom/event.rb +22 -0
- data/client/hyalite/dom/event/keyboard_event.rb +13 -0
- data/client/hyalite/dom/event/mouse_event.rb +10 -0
- data/client/hyalite/dom/node.rb +71 -0
- data/client/hyalite/dom/text.rb +14 -0
- data/client/hyalite/dom_component.rb +14 -16
- data/client/hyalite/dom_property_operations.rb +8 -8
- data/client/hyalite/event_plugin/change_event_plugin.rb +0 -6
- data/client/hyalite/mount.rb +22 -26
- data/client/hyalite/multi_children.rb +6 -7
- data/client/hyalite/reconcile_transaction.rb +1 -0
- data/client/hyalite/reconciler.rb +1 -1
- data/hyalite.gemspec +0 -1
- data/lib/hyalite/main.rb +0 -1
- data/lib/hyalite/version.rb +1 -1
- metadata +14 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7727408125169943f9effd8021f8d06202219b08
|
4
|
+
data.tar.gz: ae82044f900d23b12ae3d0889b0b349caa711629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4a4e5c3c35ce98a381d64a6565a00ea923d07a78085f2a8251d4e907cfdebbb3784d94b6365f44b42e4c76021bcfbcd3d490483a2c60dee0888f0f948961bcb
|
7
|
+
data.tar.gz: 6f0a78e78b053f182e2ad3c961cb93df72df65de0f7ecd3a5be9f2dee3acefaa82799a1290f1615f8a6b22c56f29f440c4b68b194bb964a961204769e3f3e1c2
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.3
|
data/.travis.yml
CHANGED
@@ -1,3 +1,8 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
2.3.
|
3
|
+
2.3.3
|
4
|
+
before_script:
|
5
|
+
- mkdir travis-phantomjs
|
6
|
+
- wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
|
7
|
+
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs
|
8
|
+
- export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,28 +3,23 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
hyalite (0.0.6)
|
5
5
|
opal
|
6
|
-
opal-browser
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
10
9
|
specs:
|
11
|
-
concurrent-ruby (1.0.
|
10
|
+
concurrent-ruby (1.0.4)
|
12
11
|
hike (1.2.3)
|
13
|
-
opal (0.
|
12
|
+
opal (0.10.3)
|
14
13
|
hike (~> 1.2)
|
15
14
|
sourcemap (~> 0.1.0)
|
16
15
|
sprockets (~> 3.1)
|
17
16
|
tilt (>= 1.4)
|
18
|
-
opal-
|
19
|
-
opal
|
20
|
-
paggio
|
21
|
-
opal-rspec (0.5.0)
|
22
|
-
opal (>= 0.8.0, < 0.10)
|
23
|
-
paggio (0.2.6)
|
17
|
+
opal-rspec (0.6.0)
|
18
|
+
opal (>= 0.10.0, < 0.11)
|
24
19
|
rack (2.0.1)
|
25
20
|
rake (10.5.0)
|
26
21
|
sourcemap (0.1.1)
|
27
|
-
sprockets (3.7.
|
22
|
+
sprockets (3.7.1)
|
28
23
|
concurrent-ruby (~> 1.0)
|
29
24
|
rack (> 1, < 3)
|
30
25
|
tilt (2.0.5)
|
@@ -35,8 +30,8 @@ PLATFORMS
|
|
35
30
|
DEPENDENCIES
|
36
31
|
bundler (~> 1.8)
|
37
32
|
hyalite!
|
38
|
-
opal-rspec
|
39
|
-
rake
|
33
|
+
opal-rspec
|
34
|
+
rake
|
40
35
|
|
41
36
|
BUNDLED WITH
|
42
37
|
1.13.6
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'opal'
|
2
|
-
require 'opal-browser'
|
3
2
|
require 'opal/rspec/rake_task'
|
4
3
|
require "bundler/gem_tasks"
|
5
4
|
|
6
|
-
Opal::
|
5
|
+
Opal::Config.source_map_enabled = true
|
7
6
|
|
8
7
|
Opal::RSpec::RakeTask.new(:default) do |server, task|
|
8
|
+
task.files = [ENV['FILE']] if ENV['FILE']
|
9
9
|
server.append_path File.expand_path('../client', __FILE__)
|
10
10
|
server.source_map = true
|
11
11
|
server.debug = true
|
data/client/hyalite.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'opal'
|
2
|
-
require 'browser'
|
3
2
|
require 'hyalite/logger'
|
4
3
|
require 'hyalite/transaction'
|
5
4
|
require 'hyalite/adler32'
|
@@ -7,6 +6,7 @@ require 'hyalite/mount'
|
|
7
6
|
require 'hyalite/element'
|
8
7
|
require 'hyalite/dom_component'
|
9
8
|
require 'hyalite/text_component'
|
9
|
+
require 'hyalite/dom'
|
10
10
|
|
11
11
|
module Hyalite
|
12
12
|
class << self
|
@@ -87,7 +87,7 @@ module Hyalite
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def render(next_element, container, &block)
|
90
|
-
Mount.render_subtree_into_container(
|
90
|
+
Mount.render_subtree_into_container(next_element, container, &block);
|
91
91
|
end
|
92
92
|
|
93
93
|
def instance_map
|
@@ -108,7 +108,7 @@ module Hyalite
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def find_dom_node(component_or_element)
|
111
|
-
return component_or_element if component_or_element.respond_to?(:node_type) && component_or_element.
|
111
|
+
return component_or_element if component_or_element.respond_to?(:node_type) && component_or_element.element?
|
112
112
|
|
113
113
|
if instance_map.has_key?(component_or_element)
|
114
114
|
return Mount.node(instance_map[component_or_element].root_node_id)
|
data/client/hyalite/component.rb
CHANGED
@@ -25,9 +25,8 @@ module Hyalite
|
|
25
25
|
@mount_order = CompositeComponent.next_mount_id
|
26
26
|
@root_node_id = root_id
|
27
27
|
|
28
|
-
public_context = mask_context(@context)
|
29
28
|
@instance = @current_element.type.new
|
30
|
-
@instance.init_component(@current_element.props,
|
29
|
+
@instance.init_component(@current_element.props, @context, UpdateQueue)
|
31
30
|
|
32
31
|
Hyalite.instance_map[@instance] = self
|
33
32
|
|
@@ -111,12 +110,8 @@ module Hyalite
|
|
111
110
|
end
|
112
111
|
end
|
113
112
|
|
114
|
-
def mask_context(context)
|
115
|
-
context.select {|k, v| @current_element.type.context_types.has_key? k }
|
116
|
-
end
|
117
|
-
|
118
113
|
def update_component(mount_ready, prev_parent_element, next_parent_element, prev_unmasked_context, next_unmasked_context)
|
119
|
-
next_context =
|
114
|
+
next_context = @context == next_unmasked_context ? @instance.context : next_unmasked_context
|
120
115
|
|
121
116
|
next_props = next_parent_element.props
|
122
117
|
next_state = process_pending_state(next_props, next_context)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hyalite
|
2
|
+
module DOM
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'native'
|
7
|
+
require_relative 'dom/event/keyboard_event'
|
8
|
+
require_relative 'dom/event/mouse_event'
|
9
|
+
require_relative 'dom/event'
|
10
|
+
require_relative 'dom/node'
|
11
|
+
require_relative 'dom/collection'
|
12
|
+
require_relative 'dom/text'
|
13
|
+
require_relative 'dom/element'
|
14
|
+
require_relative 'dom/body'
|
15
|
+
require_relative 'dom/document'
|
16
|
+
|
17
|
+
$document = Hyalite::DOM::Document.singleton
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'element'
|
2
|
+
|
3
|
+
module Hyalite::DOM
|
4
|
+
class Collection
|
5
|
+
include Native
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
def each(&block)
|
9
|
+
`self.native.length`.times do |i|
|
10
|
+
block.call Element.new(`self.native.item(i)`)
|
11
|
+
end
|
12
|
+
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def [](index)
|
17
|
+
Element.new(`self.native.item(index)`)
|
18
|
+
end
|
19
|
+
|
20
|
+
def length
|
21
|
+
`self.native.length`
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Hyalite::DOM
|
2
|
+
class Document
|
3
|
+
include Native
|
4
|
+
include Node
|
5
|
+
|
6
|
+
def create_element(tag)
|
7
|
+
Element.new `self.native.createElement(tag)`
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_text(text)
|
11
|
+
Text.new `self.native.createTextNode(text)`
|
12
|
+
end
|
13
|
+
|
14
|
+
def body
|
15
|
+
Body.new `self.native.body`
|
16
|
+
end
|
17
|
+
|
18
|
+
def ready(&block)
|
19
|
+
`self.native.addEventListener('DOMContentLoaded', block)`
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.singleton
|
23
|
+
@singleton ||= self.new(`window.document`)
|
24
|
+
end
|
25
|
+
|
26
|
+
def document?
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
def [](q)
|
31
|
+
elements = []
|
32
|
+
%x(
|
33
|
+
var nodeList = self.native.querySelectorAll(#{q});
|
34
|
+
for (var i = 0; i < nodeList.length; i++) {
|
35
|
+
elements.$push(nodeList.item(i));
|
36
|
+
}
|
37
|
+
)
|
38
|
+
elements.map!{|el| Element.new(el) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Hyalite::DOM
|
2
|
+
class Element
|
3
|
+
include Native
|
4
|
+
include Node
|
5
|
+
|
6
|
+
alias_native :set_attribute, :setAttribute
|
7
|
+
alias_native :get_attribute, :getAttribute
|
8
|
+
alias_native :remove_attribute, :removeAttribute
|
9
|
+
alias_native :tag_name, :tagName
|
10
|
+
|
11
|
+
def element?
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def input_type
|
16
|
+
`self.native.type`
|
17
|
+
end
|
18
|
+
|
19
|
+
def [](prop_name)
|
20
|
+
`self.native[#{prop_name}]`
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_class(name)
|
24
|
+
`self.native.classList.add(name)`
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def class_names
|
29
|
+
Array.new(`self.native.classList`).to_a
|
30
|
+
end
|
31
|
+
|
32
|
+
def attributes
|
33
|
+
@attributes ||= Attributes.new(self)
|
34
|
+
end
|
35
|
+
|
36
|
+
def text
|
37
|
+
`self.native.textContent`
|
38
|
+
end
|
39
|
+
|
40
|
+
def text=(text)
|
41
|
+
`self.native.textContent = text`
|
42
|
+
end
|
43
|
+
|
44
|
+
def value
|
45
|
+
`self.native.value`
|
46
|
+
end
|
47
|
+
|
48
|
+
def style(hash)
|
49
|
+
hash.each do |key, value|
|
50
|
+
`self.native.style[key] = value`
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_child(child)
|
55
|
+
`self.native.appendChild(child.native)`
|
56
|
+
end
|
57
|
+
|
58
|
+
def inner_html
|
59
|
+
`self.native.innerHTML`
|
60
|
+
end
|
61
|
+
|
62
|
+
def inner_html=(html)
|
63
|
+
`self.native.innerHTML = html`
|
64
|
+
end
|
65
|
+
|
66
|
+
def inner_dom=(dom)
|
67
|
+
clear
|
68
|
+
self << dom
|
69
|
+
end
|
70
|
+
|
71
|
+
def document
|
72
|
+
$document
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_s
|
76
|
+
"<#{`self.native.tagName`} class='#{self.class_names.join(' ')}' id='#{self['id']}'/>"
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.create(tag)
|
80
|
+
$document.create_element(tag)
|
81
|
+
end
|
82
|
+
|
83
|
+
class Attributes
|
84
|
+
def initialize(element)
|
85
|
+
@element = element
|
86
|
+
end
|
87
|
+
|
88
|
+
def [](name)
|
89
|
+
@element.get_attribute(name)
|
90
|
+
end
|
91
|
+
|
92
|
+
def []=(name, value)
|
93
|
+
@element.set_attribute(name, value)
|
94
|
+
end
|
95
|
+
|
96
|
+
def remove(name)
|
97
|
+
@element.remove_attribute(name)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Hyalite
|
2
|
+
module DOM
|
3
|
+
module Event
|
4
|
+
EVENT_CLASSES = {
|
5
|
+
'click' => MouseEvent,
|
6
|
+
'keydown' => KeyboardEvent
|
7
|
+
}
|
8
|
+
|
9
|
+
def self.create(event)
|
10
|
+
type = `event.type`
|
11
|
+
event_class = EVENT_CLASSES[type]
|
12
|
+
if event_class
|
13
|
+
event_class.new(event)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def target
|
18
|
+
Node.create(`self.native.target`)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Hyalite::DOM
|
2
|
+
module Node
|
3
|
+
|
4
|
+
def self.create(node)
|
5
|
+
@classes ||= [nil, Element, nil, Text, nil, nil, nil, nil, nil, Document, nil, nil]
|
6
|
+
|
7
|
+
if klass = @classes[`node.nodeType`]
|
8
|
+
klass.new(node)
|
9
|
+
else
|
10
|
+
raise ArgumentError, 'cannot instantiate a non derived Node object'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def document?
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def element?
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
def text?
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
def node_name
|
27
|
+
`self.native.tagName`
|
28
|
+
end
|
29
|
+
|
30
|
+
def <<(child)
|
31
|
+
`self.native.appendChild(child.native)`
|
32
|
+
end
|
33
|
+
|
34
|
+
def clear
|
35
|
+
%x(
|
36
|
+
var len = self.native.childNodes.length;
|
37
|
+
for (var i = 0; i < len; i++) {
|
38
|
+
self.native.childNodes[0].remove();
|
39
|
+
}
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def parent
|
44
|
+
if parent = `self.native.parentNode`
|
45
|
+
Node.create(parent)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def children
|
50
|
+
Collection.new `self.native.childNodes`
|
51
|
+
end
|
52
|
+
|
53
|
+
def remove
|
54
|
+
`self.native.remove()`
|
55
|
+
end
|
56
|
+
|
57
|
+
def next_sibling
|
58
|
+
sib = `self.native.nextSibling`
|
59
|
+
Node.create(sib) if sib
|
60
|
+
end
|
61
|
+
|
62
|
+
def on(name, &block)
|
63
|
+
callback = Proc.new{|event| block.call(Event.create(event))}
|
64
|
+
`self.native.addEventListener(name, callback)`
|
65
|
+
end
|
66
|
+
|
67
|
+
def ==(other)
|
68
|
+
`self.native === other.native`
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'hyalite/multi_children'
|
2
2
|
require 'hyalite/dom_property_operations'
|
3
3
|
require 'hyalite/internal_component'
|
4
|
-
require 'hyalite/browser_event'
|
5
4
|
require 'hyalite/input_wrapper'
|
6
5
|
|
7
6
|
module Hyalite
|
@@ -51,8 +50,8 @@ module Hyalite
|
|
51
50
|
# transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
|
52
51
|
end
|
53
52
|
|
54
|
-
|
55
|
-
create_content_markup(mount_ready,
|
53
|
+
markup = create_open_tag_markup_and_put_listeners(mount_ready, @element.props)
|
54
|
+
create_content_markup(mount_ready, markup, context)
|
56
55
|
end
|
57
56
|
|
58
57
|
def unmount_component
|
@@ -274,38 +273,37 @@ module Hyalite
|
|
274
273
|
|
275
274
|
#return element if mount_ready.render_to_static_markup
|
276
275
|
|
277
|
-
element[Mount::ID_ATTR_NAME] = @root_node_id
|
276
|
+
element.attributes[Mount::ID_ATTR_NAME] = @root_node_id
|
278
277
|
element
|
279
278
|
end
|
280
279
|
|
281
|
-
def create_content_markup(mount_ready,
|
280
|
+
def create_content_markup(mount_ready, markup, context)
|
282
281
|
children = @element.props[:children]
|
283
282
|
|
284
283
|
inner_html = @element.props[:dangerouslySetInnerHTML]
|
285
284
|
if inner_html
|
286
|
-
if inner_html
|
287
|
-
|
288
|
-
`element.native.innerHTML = html`
|
285
|
+
if inner_html.has_key?(:__html)
|
286
|
+
markup.inner_html = inner_html[:__html]
|
289
287
|
end
|
290
288
|
elsif is_text_content(children)
|
291
|
-
|
289
|
+
markup.text = children.to_s
|
292
290
|
else
|
293
|
-
mount_images = mount_children(
|
294
|
-
mount_images.each do |image|
|
295
|
-
if image
|
296
|
-
|
291
|
+
mount_images = mount_children(children, mount_ready, context)
|
292
|
+
mount_images.compact.each do |image|
|
293
|
+
if is_text_content(image)
|
294
|
+
markup << Hyalite::DOM::Text.new(image.to_s)
|
297
295
|
else
|
298
|
-
|
296
|
+
markup << image
|
299
297
|
end
|
300
298
|
end
|
301
299
|
end
|
302
|
-
|
300
|
+
markup
|
303
301
|
end
|
304
302
|
|
305
303
|
def enqueue_put_listener(id, event_name, listener, mount_ready)
|
306
304
|
container = Mount.container_for_id(id)
|
307
305
|
if container
|
308
|
-
doc = container.
|
306
|
+
doc = container.element? ? container.document : container
|
309
307
|
BrowserEvent.listen_to(event_name, doc)
|
310
308
|
end
|
311
309
|
mount_ready.enqueue do
|
@@ -13,15 +13,15 @@ module Hyalite
|
|
13
13
|
|
14
14
|
attribute_name = property_info[:attribute_name]
|
15
15
|
if property_info[:has_boolean_value] || property_info[:has_overloaded_boolean_value] && value == true
|
16
|
-
element[attribute_name] = ""
|
16
|
+
element.attributes[attribute_name] = ""
|
17
17
|
return
|
18
18
|
end
|
19
19
|
|
20
|
-
element[attribute_name]=Hyalite.escape_text_content_for_browser(value)
|
20
|
+
element.attributes[attribute_name]=Hyalite.escape_text_content_for_browser(value)
|
21
21
|
elsif DOMProperty.is_custom_attribute(name)
|
22
22
|
return if value.nil?
|
23
23
|
|
24
|
-
element[name]=Hyalite.escape_text_content_for_browser(value)
|
24
|
+
element.attributes[name]=Hyalite.escape_text_content_for_browser(value)
|
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[name]=Hyalite.escape_text_content_for_browser(value)
|
35
|
+
element.attributes[name]=Hyalite.escape_text_content_for_browser(value)
|
36
36
|
end
|
37
37
|
|
38
38
|
def is_attribute_name_safe(attribute_name)
|
@@ -63,12 +63,12 @@ module Hyalite
|
|
63
63
|
attribute_name = property_info[:attribute_name]
|
64
64
|
namespace = property_info[:attribute_namespace]
|
65
65
|
if namespace
|
66
|
-
node[attribute_name, {namespace: namespace}] = value.to_s
|
66
|
+
node.attributes[attribute_name, {namespace: namespace}] = value.to_s
|
67
67
|
elsif property_info[:has_boolean_value] ||
|
68
68
|
(property_info[:has_overloaded_boolean_value] && value == true)
|
69
|
-
node[attribute_name] = ''
|
69
|
+
node.attributes[attribute_name] = ''
|
70
70
|
else
|
71
|
-
node[attribute_name] = value.to_s
|
71
|
+
node.attributes[attribute_name] = value.to_s
|
72
72
|
end
|
73
73
|
else
|
74
74
|
prop_name = property_info[:property_name]
|
@@ -102,7 +102,7 @@ module Hyalite
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def set_attribute_for_id(node, id)
|
105
|
-
node[DOMProperty::ID_ATTRIBUTE_NAME] = id
|
105
|
+
node.attributes[DOMProperty::ID_ATTRIBUTE_NAME] = id
|
106
106
|
end
|
107
107
|
|
108
108
|
def should_ignore_value(property_info, value)
|
data/client/hyalite/mount.rb
CHANGED
@@ -22,7 +22,7 @@ module Hyalite
|
|
22
22
|
@instances_by_root_id[root_id]
|
23
23
|
end
|
24
24
|
|
25
|
-
def render_subtree_into_container(
|
25
|
+
def render_subtree_into_container(next_element, container, &block)
|
26
26
|
next_wrapped_element = ElementObject.new(TopLevelWrapper, nil, nil, nil, next_element)
|
27
27
|
prev_component = @instances_by_root_id[root_id(container)]
|
28
28
|
if prev_component
|
@@ -32,7 +32,6 @@ module Hyalite
|
|
32
32
|
return update_root_component(
|
33
33
|
prev_component,
|
34
34
|
next_wrapped_element,
|
35
|
-
container,
|
36
35
|
&block
|
37
36
|
).rendered_component.public_instance
|
38
37
|
else
|
@@ -47,10 +46,7 @@ module Hyalite
|
|
47
46
|
component = render_new_root_component(
|
48
47
|
next_wrapped_element,
|
49
48
|
container,
|
50
|
-
should_reuse_markup
|
51
|
-
parent_component ?
|
52
|
-
parent_component.internal_instance.process_child_context(parent_component.internal_instance.context) :
|
53
|
-
{}
|
49
|
+
should_reuse_markup
|
54
50
|
).rendered_component.public_instance
|
55
51
|
|
56
52
|
if block_given?
|
@@ -61,18 +57,18 @@ module Hyalite
|
|
61
57
|
end
|
62
58
|
|
63
59
|
def is_rendered(node)
|
64
|
-
return false
|
60
|
+
return false unless node.element?
|
65
61
|
|
66
62
|
id = node_id(node)
|
67
63
|
id ? id[0] == SEPARATOR : false
|
68
64
|
end
|
69
65
|
|
70
|
-
def render_new_root_component(next_element, container, should_reuse_markup
|
71
|
-
component_instance = Hyalite.instantiate_component(next_element
|
66
|
+
def render_new_root_component(next_element, container, should_reuse_markup)
|
67
|
+
component_instance = Hyalite.instantiate_component(next_element)
|
72
68
|
root_id = register_component(component_instance, container)
|
73
69
|
|
74
70
|
Hyalite.updates.batched_updates do
|
75
|
-
mount_component_into_node(component_instance, root_id, container, should_reuse_markup
|
71
|
+
mount_component_into_node(component_instance, root_id, container, should_reuse_markup)
|
76
72
|
end
|
77
73
|
|
78
74
|
component_instance
|
@@ -100,9 +96,9 @@ module Hyalite
|
|
100
96
|
root_id
|
101
97
|
end
|
102
98
|
|
103
|
-
def mount_component_into_node(component_instance, root_id, container, should_reuse_markup
|
99
|
+
def mount_component_into_node(component_instance, root_id, container, should_reuse_markup)
|
104
100
|
Hyalite.updates.reconcile_transaction.perform do |transaction|
|
105
|
-
markup = Reconciler.mount_component(component_instance, root_id, transaction.mount_ready,
|
101
|
+
markup = Reconciler.mount_component(component_instance, root_id, transaction.mount_ready, {})
|
106
102
|
component_instance.rendered_component.top_level_wrapper = component_instance
|
107
103
|
mount_image_into_node(markup, container, should_reuse_markup)
|
108
104
|
end
|
@@ -112,23 +108,23 @@ module Hyalite
|
|
112
108
|
if should_reuse_markup
|
113
109
|
root_element = root_element_in_container(container)
|
114
110
|
checksum = Adler32.checksum markup
|
115
|
-
checksum_attr = root_element.
|
111
|
+
checksum_attr = root_element.attributes[CHECKSUM_ATTR_NAME]
|
116
112
|
if checksum == checksum_attr
|
117
113
|
return
|
118
114
|
end
|
119
115
|
|
120
|
-
root_element.
|
121
|
-
root_element.
|
116
|
+
root_element.attributes.remove(CHECKSUM_ATTR_NAME)
|
117
|
+
root_element.attributes[CHECKSUM_ATTR_NAME] = checksum
|
122
118
|
end
|
123
119
|
|
124
120
|
container.inner_dom = markup
|
125
121
|
end
|
126
122
|
|
127
123
|
def root_element_in_container(container)
|
128
|
-
if container.
|
124
|
+
if container.document?
|
129
125
|
$document
|
130
126
|
else
|
131
|
-
container.
|
127
|
+
container.children.first
|
132
128
|
end
|
133
129
|
end
|
134
130
|
|
@@ -163,8 +159,8 @@ module Hyalite
|
|
163
159
|
end
|
164
160
|
|
165
161
|
def internal_id(node)
|
166
|
-
if node.
|
167
|
-
node.
|
162
|
+
if node.element?
|
163
|
+
node.attributes[ID_ATTR_NAME]
|
168
164
|
end
|
169
165
|
end
|
170
166
|
|
@@ -197,7 +193,7 @@ module Hyalite
|
|
197
193
|
def find_component_root(ancestor_node, target_id)
|
198
194
|
deepest_ancestor = find_deepest_cached_ancestor(target_id) || ancestor_node
|
199
195
|
|
200
|
-
first_children = [ deepest_ancestor.
|
196
|
+
first_children = [ deepest_ancestor.children.first ]
|
201
197
|
|
202
198
|
while first_children.length > 0
|
203
199
|
child = first_children.shift
|
@@ -208,10 +204,10 @@ module Hyalite
|
|
208
204
|
if target_id == child_id
|
209
205
|
return child
|
210
206
|
elsif InstanceHandles.is_ancestor_id_of(child_id, target_id)
|
211
|
-
first_children = [ child.
|
207
|
+
first_children = [ child.children.first ]
|
212
208
|
end
|
213
209
|
else
|
214
|
-
first_children.push(child.
|
210
|
+
first_children.push(child.children.first)
|
215
211
|
end
|
216
212
|
|
217
213
|
child = child.next_sibling
|
@@ -241,7 +237,7 @@ module Hyalite
|
|
241
237
|
false
|
242
238
|
when outer_node == inner_node
|
243
239
|
true
|
244
|
-
when outer_node.
|
240
|
+
when outer_node.text?
|
245
241
|
false
|
246
242
|
else
|
247
243
|
contains_node(outer_node, inner_node.parent)
|
@@ -249,8 +245,8 @@ module Hyalite
|
|
249
245
|
end
|
250
246
|
|
251
247
|
def find_first_hyalite_dom(node)
|
252
|
-
while node && node.parent
|
253
|
-
unless node.
|
248
|
+
while node && node.parent
|
249
|
+
unless node.element? && node_id = internal_id(node)
|
254
250
|
node = node.parent
|
255
251
|
next
|
256
252
|
end
|
@@ -272,7 +268,7 @@ module Hyalite
|
|
272
268
|
nil
|
273
269
|
end
|
274
270
|
|
275
|
-
def update_root_component(prev_component, next_element,
|
271
|
+
def update_root_component(prev_component, next_element, &callback)
|
276
272
|
UpdateQueue.enqueue_element_internal(prev_component, next_element)
|
277
273
|
if block_given?
|
278
274
|
UpdateQueue.enqueue_callback_internal(prev_component, &callback)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Hyalite
|
2
2
|
module MultiChildren
|
3
3
|
def mount_children(nested_children, mount_ready, context)
|
4
|
-
children = instantiate_children(nested_children,
|
4
|
+
children = instantiate_children(nested_children, context)
|
5
5
|
@rendered_children = children
|
6
6
|
index = 0
|
7
7
|
children.keys.map do |name|
|
@@ -86,7 +86,7 @@ module Hyalite
|
|
86
86
|
|
87
87
|
def instantiate_children(nested_child_nodes, context)
|
88
88
|
Reconciler.flatten_children(nested_child_nodes).map {|name, child|
|
89
|
-
child_instance = Hyalite.instantiate_component(child
|
89
|
+
child_instance = Hyalite.instantiate_component(child)
|
90
90
|
[name, child_instance]
|
91
91
|
}.to_h
|
92
92
|
end
|
@@ -152,7 +152,7 @@ module Hyalite
|
|
152
152
|
updates.each_with_index do |update, updated_index|
|
153
153
|
if update[:type] == :move_existing || update[:type] == :remove_node
|
154
154
|
updated_index = update[:fromIndex]
|
155
|
-
updated_child = update[:parentNode].
|
155
|
+
updated_child = update[:parentNode].children[updated_index]
|
156
156
|
parent_id = update[:parentID]
|
157
157
|
|
158
158
|
initial_children[parent_id] ||= []
|
@@ -188,19 +188,18 @@ module Hyalite
|
|
188
188
|
when :set_markup
|
189
189
|
update[:parentNode].inner_html = update[:textContent]
|
190
190
|
when :text_content
|
191
|
-
update[:parentNode].
|
191
|
+
update[:parentNode].text = update[:textContent]
|
192
192
|
when :remove_node
|
193
193
|
# Already removed above.
|
194
194
|
end
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
|
-
|
199
198
|
def insert_child_at(parent_node, child_node, index)
|
200
|
-
if index >= parent_node.children.
|
199
|
+
if index >= parent_node.children.length
|
201
200
|
parent_node.add_child(child_node)
|
202
201
|
else
|
203
|
-
parent_node.children
|
202
|
+
parent_node.children[index].add_previous_sibling(child_node)
|
204
203
|
end
|
205
204
|
end
|
206
205
|
end
|
data/hyalite.gemspec
CHANGED
data/lib/hyalite/main.rb
CHANGED
data/lib/hyalite/version.rb
CHANGED
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youchan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: opal-browser
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +60,7 @@ extensions: []
|
|
74
60
|
extra_rdoc_files: []
|
75
61
|
files:
|
76
62
|
- ".gitignore"
|
63
|
+
- ".ruby-version"
|
77
64
|
- ".travis.yml"
|
78
65
|
- Gemfile
|
79
66
|
- Gemfile.lock
|
@@ -86,6 +73,16 @@ files:
|
|
86
73
|
- client/hyalite/callback_queue.rb
|
87
74
|
- client/hyalite/component.rb
|
88
75
|
- client/hyalite/composite_component.rb
|
76
|
+
- client/hyalite/dom.rb
|
77
|
+
- client/hyalite/dom/body.rb
|
78
|
+
- client/hyalite/dom/collection.rb
|
79
|
+
- client/hyalite/dom/document.rb
|
80
|
+
- client/hyalite/dom/element.rb
|
81
|
+
- client/hyalite/dom/event.rb
|
82
|
+
- client/hyalite/dom/event/keyboard_event.rb
|
83
|
+
- client/hyalite/dom/event/mouse_event.rb
|
84
|
+
- client/hyalite/dom/node.rb
|
85
|
+
- client/hyalite/dom/text.rb
|
89
86
|
- client/hyalite/dom_component.rb
|
90
87
|
- client/hyalite/dom_operations.rb
|
91
88
|
- client/hyalite/dom_property.rb
|
@@ -142,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
139
|
version: '0'
|
143
140
|
requirements: []
|
144
141
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.5.
|
142
|
+
rubygems_version: 2.5.2
|
146
143
|
signing_key:
|
147
144
|
specification_version: 4
|
148
145
|
summary: Virtual DOM implimentation in Ruby
|