volt 0.8.15 → 0.8.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +1 -1
- data/Guardfile +2 -3
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +1 -1
- data/app/volt/tasks/live_query/data_store.rb +7 -7
- data/app/volt/tasks/live_query/live_query.rb +7 -9
- data/app/volt/tasks/live_query/live_query_pool.rb +13 -12
- data/app/volt/tasks/live_query/query_tracker.rb +4 -5
- data/app/volt/tasks/query_tasks.rb +9 -11
- data/app/volt/tasks/store_tasks.rb +4 -4
- data/app/volt/tasks/user_tasks.rb +1 -1
- data/bin/volt +2 -2
- data/lib/volt.rb +3 -7
- data/lib/volt/assets/test.rb +1 -2
- data/lib/volt/benchmark/benchmark.rb +3 -3
- data/lib/volt/boot.rb +1 -1
- data/lib/volt/cli.rb +18 -18
- data/lib/volt/cli/asset_compile.rb +8 -10
- data/lib/volt/cli/generate.rb +9 -11
- data/lib/volt/cli/new_gem.rb +51 -51
- data/lib/volt/config.rb +2 -3
- data/lib/volt/console.rb +1 -1
- data/lib/volt/controllers/model_controller.rb +6 -6
- data/lib/volt/data_stores/data_store.rb +1 -1
- data/lib/volt/data_stores/mongo_driver.rb +1 -1
- data/lib/volt/extra_core/array.rb +2 -2
- data/lib/volt/extra_core/blank.rb +1 -2
- data/lib/volt/extra_core/extra_core.rb +1 -1
- data/lib/volt/extra_core/inflector/methods.rb +0 -1
- data/lib/volt/extra_core/logger.rb +13 -7
- data/lib/volt/extra_core/numeric.rb +1 -1
- data/lib/volt/extra_core/string.rb +7 -7
- data/lib/volt/extra_core/stringify_keys.rb +5 -5
- data/lib/volt/models.rb +2 -2
- data/lib/volt/models/array_model.rb +18 -19
- data/lib/volt/models/cursor.rb +0 -1
- data/lib/volt/models/model.rb +17 -35
- data/lib/volt/models/model_hash_behaviour.rb +0 -2
- data/lib/volt/models/model_state.rb +1 -1
- data/lib/volt/models/model_wrapper.rb +1 -1
- data/lib/volt/models/persistors/array_store.rb +26 -13
- data/lib/volt/models/persistors/base.rb +1 -1
- data/lib/volt/models/persistors/flash.rb +2 -2
- data/lib/volt/models/persistors/local_store.rb +2 -3
- data/lib/volt/models/persistors/model_store.rb +7 -6
- data/lib/volt/models/persistors/params.rb +2 -2
- data/lib/volt/models/persistors/query/query_listener.rb +2 -0
- data/lib/volt/models/persistors/query/query_listener_pool.rb +1 -1
- data/lib/volt/models/persistors/store.rb +1 -2
- data/lib/volt/models/persistors/store_state.rb +2 -3
- data/lib/volt/models/url.rb +17 -16
- data/lib/volt/models/validations.rb +11 -14
- data/lib/volt/models/validators/length_validator.rb +3 -3
- data/lib/volt/models/validators/presence_validator.rb +2 -2
- data/lib/volt/page/bindings/attribute_binding.rb +2 -3
- data/lib/volt/page/bindings/base_binding.rb +1 -1
- data/lib/volt/page/bindings/each_binding.rb +8 -9
- data/lib/volt/page/bindings/event_binding.rb +2 -3
- data/lib/volt/page/bindings/template_binding.rb +8 -7
- data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +2 -1
- data/lib/volt/page/channel.rb +10 -10
- data/lib/volt/page/channel_stub.rb +1 -1
- data/lib/volt/page/document.rb +0 -1
- data/lib/volt/page/document_events.rb +4 -4
- data/lib/volt/page/page.rb +26 -19
- data/lib/volt/page/string_template_renderer.rb +2 -2
- data/lib/volt/page/sub_context.rb +10 -4
- data/lib/volt/page/targets/attribute_section.rb +1 -1
- data/lib/volt/page/targets/attribute_target.rb +1 -2
- data/lib/volt/page/targets/base_section.rb +4 -4
- data/lib/volt/page/targets/binding_document/base_node.rb +0 -1
- data/lib/volt/page/targets/binding_document/component_node.rb +4 -5
- data/lib/volt/page/targets/dom_section.rb +21 -22
- data/lib/volt/page/targets/dom_target.rb +1 -1
- data/lib/volt/page/targets/dom_template.rb +11 -12
- data/lib/volt/page/targets/helpers/comment_searchers.rb +7 -8
- data/lib/volt/page/tasks.rb +0 -1
- data/lib/volt/page/template_renderer.rb +1 -1
- data/lib/volt/page/url_tracker.rb +3 -3
- data/lib/volt/reactive/computation.rb +5 -11
- data/lib/volt/reactive/dependency.rb +1 -3
- data/lib/volt/reactive/eventable.rb +17 -4
- data/lib/volt/reactive/hash_dependency.rb +1 -0
- data/lib/volt/reactive/reactive_accessors.rb +0 -1
- data/lib/volt/reactive/reactive_array.rb +20 -25
- data/lib/volt/reactive/reactive_hash.rb +3 -3
- data/lib/volt/router/routes.rb +11 -13
- data/lib/volt/server.rb +17 -17
- data/lib/volt/server/component_handler.rb +2 -2
- data/lib/volt/server/component_templates.rb +8 -8
- data/lib/volt/server/html_parser/attribute_scope.rb +9 -10
- data/lib/volt/server/html_parser/if_view_scope.rb +2 -2
- data/lib/volt/server/html_parser/sandlebars_parser.rb +14 -14
- data/lib/volt/server/html_parser/textarea_scope.rb +1 -2
- data/lib/volt/server/html_parser/view_handler.rb +1 -1
- data/lib/volt/server/html_parser/view_parser.rb +1 -1
- data/lib/volt/server/html_parser/view_scope.rb +10 -10
- data/lib/volt/server/rack/asset_files.rb +15 -16
- data/lib/volt/server/rack/component_code.rb +2 -2
- data/lib/volt/server/rack/component_html_renderer.rb +0 -1
- data/lib/volt/server/rack/component_paths.rb +13 -10
- data/lib/volt/server/rack/index_files.rb +4 -4
- data/lib/volt/server/rack/opal_files.rb +4 -5
- data/lib/volt/server/rack/source_map_server.rb +3 -3
- data/lib/volt/server/socket_connection_handler.rb +3 -4
- data/lib/volt/server/socket_connection_handler_stub.rb +1 -1
- data/lib/volt/spec/setup.rb +3 -3
- data/lib/volt/store/mongo.rb +2 -2
- data/lib/volt/tasks/task_handler.rb +3 -3
- data/lib/volt/utils/generic_counting_pool.rb +2 -2
- data/lib/volt/utils/generic_pool.rb +7 -8
- data/lib/volt/utils/local_storage.rb +4 -4
- data/lib/volt/volt/environment.rb +1 -1
- data/spec/apps/file_loading/app/shared/config/dependencies.rb +1 -1
- data/spec/apps/kitchen_sink/Gemfile +0 -2
- data/spec/apps/kitchen_sink/app/main/config/routes.rb +5 -5
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +7 -6
- data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +3 -4
- data/spec/controllers/reactive_accessors_spec.rb +4 -4
- data/spec/extra_core/inflector_spec.rb +1 -1
- data/spec/extra_core/string_transformation_test_cases.rb +23 -24
- data/spec/extra_core/string_transformations_spec.rb +11 -12
- data/spec/integration/bindings_spec.rb +15 -15
- data/spec/integration/list_spec.rb +12 -13
- data/spec/integration/templates_spec.rb +3 -3
- data/spec/models/model_spec.rb +74 -80
- data/spec/models/persistors/params_spec.rb +2 -2
- data/spec/models/persistors/store_spec.rb +4 -4
- data/spec/models/validations_spec.rb +14 -23
- data/spec/page/bindings/content_binding_spec.rb +7 -8
- data/spec/page/bindings/template_binding_spec.rb +22 -24
- data/spec/page/sub_context_spec.rb +2 -2
- data/spec/reactive/computation_spec.rb +3 -3
- data/spec/reactive/reactive_array_spec.rb +12 -12
- data/spec/router/routes_spec.rb +45 -48
- data/spec/server/html_parser/sandlebars_parser_spec.rb +42 -42
- data/spec/server/html_parser/view_parser_spec.rb +132 -153
- data/spec/server/rack/asset_files_spec.rb +9 -8
- data/spec/server/rack/component_paths_spec.rb +5 -5
- data/spec/server/rack/rack_requests_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/tasks/live_query_spec.rb +4 -5
- data/spec/tasks/query_tasks.rb +2 -4
- data/spec/tasks/query_tracker_spec.rb +29 -29
- data/spec/templates/targets/binding_document/component_node_spec.rb +1 -1
- data/spec/utils/generic_counting_pool_spec.rb +4 -4
- data/spec/utils/generic_pool_spec.rb +12 -12
- data/templates/component/config/routes.rb +2 -2
- data/templates/component/controllers/main_controller.rb +7 -6
- data/templates/newgem/app/newgem/config/dependencies.rb +1 -1
- data/templates/newgem/app/newgem/config/routes.rb +1 -1
- data/templates/project/app/main/config/routes.rb +2 -2
- data/templates/project/app/main/controllers/main_controller.rb +7 -6
- data/templates/project/spec/sample_spec.rb +2 -2
- data/volt.gemspec +32 -33
- metadata +3 -4
- data/lib/volt/extra_core/log.rb +0 -56
- data/lib/volt/extra_core/try.rb +0 -31
@@ -11,7 +11,7 @@ module Volt
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def get
|
14
|
-
|
14
|
+
(controller = self.controller) && controller[0]
|
15
15
|
end
|
16
16
|
|
17
17
|
def set(controller)
|
@@ -31,6 +31,7 @@ module Volt
|
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
|
+
|
34
35
|
def controller
|
35
36
|
@@controllers[@name]
|
36
37
|
end
|
data/lib/volt/page/channel.rb
CHANGED
@@ -23,11 +23,11 @@ module Volt
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def connected?
|
26
|
-
|
26
|
+
connected
|
27
27
|
end
|
28
28
|
|
29
29
|
def connect!
|
30
|
-
|
30
|
+
`
|
31
31
|
this.socket = new SockJS('/channel');
|
32
32
|
|
33
33
|
this.socket.onopen = function() {
|
@@ -41,7 +41,7 @@ module Volt
|
|
41
41
|
this.socket.onclose = function(error) {
|
42
42
|
self.$closed(error);
|
43
43
|
};
|
44
|
-
|
44
|
+
`
|
45
45
|
end
|
46
46
|
|
47
47
|
def opened
|
@@ -71,11 +71,11 @@ module Volt
|
|
71
71
|
|
72
72
|
interval = self.reconnect_interval
|
73
73
|
|
74
|
-
|
74
|
+
`
|
75
75
|
setTimeout(function() {
|
76
76
|
self['$connect!']();
|
77
77
|
}, interval);
|
78
|
-
|
78
|
+
`
|
79
79
|
end
|
80
80
|
|
81
81
|
def message_received(message)
|
@@ -85,22 +85,22 @@ module Volt
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def send_message(message)
|
88
|
-
if
|
88
|
+
if status != :open
|
89
89
|
@queue << message
|
90
90
|
else
|
91
91
|
# TODO: Temp: wrap message in an array, so we're sure its valid JSON
|
92
92
|
message = JSON.dump([message])
|
93
|
-
|
93
|
+
`
|
94
94
|
this.socket.send(message);
|
95
|
-
|
95
|
+
`
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
def close!
|
100
100
|
self.status = :closed
|
101
|
-
|
101
|
+
`
|
102
102
|
this.socket.close();
|
103
|
-
|
103
|
+
`
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
data/lib/volt/page/document.rb
CHANGED
@@ -14,11 +14,11 @@ module Volt
|
|
14
14
|
|
15
15
|
that = self
|
16
16
|
|
17
|
-
|
17
|
+
`
|
18
18
|
$('body').on(event, function(e) {
|
19
19
|
that.$handle(event, e, e.target || e.originalEvent.target);
|
20
20
|
});
|
21
|
-
|
21
|
+
`
|
22
22
|
|
23
23
|
end
|
24
24
|
|
@@ -70,9 +70,9 @@ module Volt
|
|
70
70
|
@events.delete(event)
|
71
71
|
|
72
72
|
# Remove the event from the body
|
73
|
-
|
73
|
+
`
|
74
74
|
$('body').unbind(event);
|
75
|
-
|
75
|
+
`
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
data/lib/volt/page/page.rb
CHANGED
@@ -47,7 +47,7 @@ module Volt
|
|
47
47
|
|
48
48
|
if RUBY_PLATFORM == 'opal'
|
49
49
|
# Setup escape binding for console
|
50
|
-
|
50
|
+
`
|
51
51
|
$(document).keyup(function(e) {
|
52
52
|
if (e.keyCode == 27) {
|
53
53
|
Opal.gvars.page.$launch_console();
|
@@ -57,18 +57,18 @@ module Volt
|
|
57
57
|
$(document).on('click', 'a', function(event) {
|
58
58
|
return Opal.gvars.page.$link_clicked($(this).attr('href'), event);
|
59
59
|
});
|
60
|
-
|
60
|
+
`
|
61
61
|
end
|
62
62
|
|
63
63
|
# Initialize tasks so we can get the reload message
|
64
|
-
|
64
|
+
tasks if Volt.env.development?
|
65
65
|
|
66
66
|
if Volt.client?
|
67
67
|
channel.on('reconnected') do
|
68
68
|
@page._reconnected = true
|
69
69
|
|
70
70
|
`setTimeout(function() {`
|
71
|
-
|
71
|
+
@page._reconnected = false
|
72
72
|
`}, 2000);`
|
73
73
|
end
|
74
74
|
end
|
@@ -90,7 +90,7 @@ module Volt
|
|
90
90
|
@tasks ||= Tasks.new(self)
|
91
91
|
end
|
92
92
|
|
93
|
-
def link_clicked(url='', event=nil)
|
93
|
+
def link_clicked(url = '', event = nil)
|
94
94
|
# Skip when href == ''
|
95
95
|
return false if url.blank?
|
96
96
|
|
@@ -111,7 +111,7 @@ module Volt
|
|
111
111
|
# end
|
112
112
|
|
113
113
|
# Not stopping, process link normally
|
114
|
-
|
114
|
+
true
|
115
115
|
end
|
116
116
|
|
117
117
|
# We provide a binding_name, so we can bind events on the document
|
@@ -120,7 +120,7 @@ module Volt
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def launch_console
|
123
|
-
puts
|
123
|
+
puts 'Launch Console'
|
124
124
|
end
|
125
125
|
|
126
126
|
def channel
|
@@ -133,9 +133,7 @@ module Volt
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
|
137
|
-
@events
|
138
|
-
end
|
136
|
+
attr_reader :events
|
139
137
|
|
140
138
|
def add_model(model_name)
|
141
139
|
model_name = model_name.camelize.to_sym
|
@@ -143,8 +141,17 @@ module Volt
|
|
143
141
|
end
|
144
142
|
|
145
143
|
def add_template(name, template, bindings)
|
146
|
-
@templates
|
147
|
-
|
144
|
+
@templates ||= {}
|
145
|
+
|
146
|
+
# First template gets priority. The backend will load templates in order so
|
147
|
+
# that local templates come in before gems (so they can be overridden).
|
148
|
+
#
|
149
|
+
# TODO: Currently this means we will send templates to the client that will
|
150
|
+
# not get used because they are being overridden. Need to detect that and
|
151
|
+
# not send them.
|
152
|
+
unless @templates[name]
|
153
|
+
@templates[name] = { 'html' => template, 'bindings' => bindings }
|
154
|
+
end
|
148
155
|
# puts "Add Template: #{name}"
|
149
156
|
end
|
150
157
|
|
@@ -155,7 +162,7 @@ module Volt
|
|
155
162
|
|
156
163
|
def start
|
157
164
|
# Setup to render template
|
158
|
-
Element.find('body').html =
|
165
|
+
Element.find('body').html = '<!-- $CONTENT --><!-- $/CONTENT -->'
|
159
166
|
|
160
167
|
load_stored_page
|
161
168
|
|
@@ -168,10 +175,10 @@ module Volt
|
|
168
175
|
TemplateRenderer.new(self, DomTarget.new, main_controller, 'CONTENT', 'main/main/main/body')
|
169
176
|
|
170
177
|
# Setup title reactive template
|
171
|
-
@title_template = StringTemplateRender.new(self, main_controller,
|
178
|
+
@title_template = StringTemplateRender.new(self, main_controller, 'main/main/main/title')
|
172
179
|
|
173
180
|
# Watch for changes to the title template
|
174
|
-
|
181
|
+
proc do
|
175
182
|
title = @title_template.html.gsub(/\n/, ' ')
|
176
183
|
`document.title = title;`
|
177
184
|
end.watch!
|
@@ -186,11 +193,11 @@ module Volt
|
|
186
193
|
|
187
194
|
`page_obj_str = sessionStorage.getItem('___page');`
|
188
195
|
`if (page_obj_str) {`
|
189
|
-
|
196
|
+
`sessionStorage.removeItem('___page');`
|
190
197
|
|
191
|
-
|
192
|
-
|
193
|
-
|
198
|
+
JSON.parse(page_obj_str).each_pair do |key, value|
|
199
|
+
page.send(:"_#{key}=", value)
|
200
|
+
end
|
194
201
|
`}`
|
195
202
|
end
|
196
203
|
end
|
@@ -10,7 +10,7 @@ module Volt
|
|
10
10
|
|
11
11
|
@template_path = template_path
|
12
12
|
@target = AttributeTarget.new(nil, nil, self)
|
13
|
-
@template = TemplateRenderer.new(page, @target, context,
|
13
|
+
@template = TemplateRenderer.new(page, @target, context, 'main', template_path)
|
14
14
|
end
|
15
15
|
|
16
16
|
# Render the template and get the current value
|
@@ -22,7 +22,7 @@ module Volt
|
|
22
22
|
html = @target.to_html
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
html
|
26
26
|
end
|
27
27
|
|
28
28
|
def changed!
|
@@ -2,21 +2,25 @@ module Volt
|
|
2
2
|
# A sub context takes in a hash of local variables that should be available
|
3
3
|
# in front of the current context. It basically proxies the local variables
|
4
4
|
# first, then failing those proxies the context.
|
5
|
+
#
|
6
|
+
# SubContext is also used for the attrs in controllers. You can pass return_nils
|
7
|
+
# to have missing values return nil (as in attrs).
|
5
8
|
class SubContext
|
6
9
|
attr_reader :locals
|
7
10
|
|
8
|
-
def initialize(locals, context=nil)
|
11
|
+
def initialize(locals, context = nil, return_nils = false)
|
9
12
|
@locals = locals.stringify_keys
|
10
13
|
@context = context
|
14
|
+
@return_nils = return_nils
|
11
15
|
end
|
12
16
|
|
13
17
|
def respond_to?(method_name)
|
14
|
-
!!(@locals[method_name.to_s] || (@context && @context.respond_to?(method_name))
|
18
|
+
!!(@locals[method_name.to_s] || (@context && @context.respond_to?(method_name)))
|
15
19
|
end
|
16
20
|
|
17
21
|
def method_missing(method_name, *args, &block)
|
18
22
|
method_name = method_name.to_s
|
19
|
-
if @locals.
|
23
|
+
if @locals.key?(method_name)
|
20
24
|
obj = @locals[method_name]
|
21
25
|
|
22
26
|
# TODORW: Might get a normal proc, flag internal procs
|
@@ -24,11 +28,13 @@ module Volt
|
|
24
28
|
obj = obj.call(*args)
|
25
29
|
end
|
26
30
|
return obj
|
31
|
+
elsif @return_nils && method_name[-1] != '='
|
32
|
+
return nil
|
27
33
|
elsif @context
|
28
34
|
return @context.send(method_name, *args, &block)
|
29
35
|
end
|
30
36
|
|
31
|
-
|
37
|
+
fail NoMethodError.new("undefined method `#{method_name}' for \"#{inspect}\":#{self.class}")
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
@@ -7,9 +7,8 @@ module Volt
|
|
7
7
|
# AttributeTarget's provide an interface that can render bindings into
|
8
8
|
# a string that can then be used to update a attribute binding.
|
9
9
|
class AttributeTarget < ComponentNode
|
10
|
-
|
11
10
|
def dom_section(*args)
|
12
|
-
|
11
|
+
AttributeSection.new(self, *args)
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
require 'volt/page/targets/dom_template'
|
2
2
|
|
3
3
|
module Volt
|
4
|
-
# Class to describe the interface for sections
|
4
|
+
# Class to describe the interface for sections
|
5
5
|
class BaseSection
|
6
6
|
@@template_cache = {}
|
7
7
|
|
8
8
|
def remove
|
9
|
-
|
9
|
+
fail 'not implemented'
|
10
10
|
end
|
11
11
|
|
12
12
|
def remove_anchors
|
13
|
-
|
13
|
+
fail 'not implemented'
|
14
14
|
end
|
15
15
|
|
16
16
|
def insert_anchor_before_end
|
17
|
-
|
17
|
+
fail 'not implemented'
|
18
18
|
end
|
19
19
|
|
20
20
|
def set_content_to_template(page, template_name)
|
@@ -11,7 +11,7 @@ module Volt
|
|
11
11
|
|
12
12
|
attr_accessor :parent, :binding_id, :nodes
|
13
13
|
|
14
|
-
def initialize(binding_id=nil, parent=nil, root=nil)
|
14
|
+
def initialize(binding_id = nil, parent = nil, root = nil)
|
15
15
|
@nodes = []
|
16
16
|
@binding_id = binding_id
|
17
17
|
@parent = parent
|
@@ -24,7 +24,6 @@ module Volt
|
|
24
24
|
else
|
25
25
|
trigger!('changed')
|
26
26
|
end
|
27
|
-
|
28
27
|
end
|
29
28
|
|
30
29
|
def text=(text)
|
@@ -72,7 +71,7 @@ module Volt
|
|
72
71
|
str << node.to_html
|
73
72
|
end
|
74
73
|
|
75
|
-
|
74
|
+
str.join('')
|
76
75
|
end
|
77
76
|
|
78
77
|
def find_by_binding_id(binding_id)
|
@@ -87,7 +86,7 @@ module Volt
|
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
90
|
-
|
89
|
+
nil
|
91
90
|
end
|
92
91
|
|
93
92
|
def remove
|
@@ -100,7 +99,7 @@ module Volt
|
|
100
99
|
end
|
101
100
|
|
102
101
|
def remove_anchors
|
103
|
-
|
102
|
+
fail 'not implemented'
|
104
103
|
|
105
104
|
@parent.nodes.delete(self)
|
106
105
|
|
@@ -10,12 +10,11 @@ module Volt
|
|
10
10
|
@end_node = find_by_comment("$/#{binding_name}")
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
13
|
def text=(value)
|
15
|
-
|
14
|
+
`
|
16
15
|
this.$range().deleteContents();
|
17
16
|
this.$range().insertNode(document.createTextNode(#{value}));
|
18
|
-
|
17
|
+
`
|
19
18
|
end
|
20
19
|
|
21
20
|
def html=(value)
|
@@ -25,18 +24,18 @@ module Volt
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def remove
|
28
|
-
range = self.range
|
27
|
+
range = self.range
|
29
28
|
|
30
|
-
|
29
|
+
`
|
31
30
|
range.deleteContents();
|
32
|
-
|
31
|
+
`
|
33
32
|
end
|
34
33
|
|
35
34
|
def remove_anchors
|
36
|
-
|
35
|
+
`
|
37
36
|
this.start_node.parentNode.removeChild(this.start_node);
|
38
37
|
this.end_node.parentNode.removeChild(this.end_node);
|
39
|
-
|
38
|
+
`
|
40
39
|
@start_node = nil
|
41
40
|
@end_node = nil
|
42
41
|
end
|
@@ -53,9 +52,9 @@ module Volt
|
|
53
52
|
# Takes in an array of dom nodes and replaces the current content
|
54
53
|
# with the new nodes
|
55
54
|
def nodes=(nodes)
|
56
|
-
range = self.range
|
55
|
+
range = self.range
|
57
56
|
|
58
|
-
|
57
|
+
`
|
59
58
|
range.deleteContents();
|
60
59
|
|
61
60
|
for (var i=nodes.length-1; i >= 0; i--) {
|
@@ -64,50 +63,50 @@ module Volt
|
|
64
63
|
node.parentNode.removeChild(node);
|
65
64
|
range.insertNode(node);
|
66
65
|
}
|
67
|
-
|
66
|
+
`
|
68
67
|
end
|
69
68
|
|
70
69
|
# Returns the nearest DOM node that contains all of the section.
|
71
70
|
def container_node
|
72
|
-
range = self.range
|
73
|
-
|
71
|
+
range = self.range
|
72
|
+
`range.commonAncestorContainer`
|
74
73
|
end
|
75
74
|
|
76
75
|
def set_template(dom_template)
|
77
76
|
dom_nodes, bindings = dom_template.make_new
|
78
77
|
|
79
78
|
children = nil
|
80
|
-
|
79
|
+
`
|
81
80
|
children = dom_nodes.childNodes;
|
82
|
-
|
81
|
+
`
|
83
82
|
|
84
83
|
# Update the nodes
|
85
84
|
self.nodes = children
|
86
85
|
|
87
|
-
|
86
|
+
`
|
88
87
|
dom_nodes = null;
|
89
|
-
|
88
|
+
`
|
90
89
|
|
91
|
-
|
90
|
+
bindings
|
92
91
|
end
|
93
92
|
|
94
93
|
def range
|
95
94
|
return @range if @range
|
96
95
|
|
97
96
|
range = nil
|
98
|
-
|
97
|
+
`
|
99
98
|
range = document.createRange();
|
100
99
|
range.setStartAfter(this.start_node);
|
101
100
|
range.setEndBefore(this.end_node);
|
102
|
-
|
101
|
+
`
|
103
102
|
|
104
103
|
@range = range
|
105
104
|
|
106
|
-
|
105
|
+
range
|
107
106
|
end
|
108
107
|
|
109
108
|
def inspect
|
110
|
-
"<#{self.class
|
109
|
+
"<#{self.class}>"
|
111
110
|
end
|
112
111
|
end
|
113
112
|
end
|