Skip to content

Commit 954658a

Browse files
committed
closes #57
1 parent 700b8a9 commit 954658a

File tree

4 files changed

+46
-13
lines changed

4 files changed

+46
-13
lines changed

ruby/examples/misc/stock-tickers/Gemfile.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
PATH
22
remote: ../../../hyper-component
33
specs:
4-
hyper-component (1.0.pre.alpha1)
5-
hyper-state (= 1.0.pre.alpha1)
6-
hyperstack-config (= 1.0.pre.alpha1)
4+
hyper-component (1.0.alpha1)
5+
hyper-state (= 1.0.alpha1)
6+
hyperstack-config (= 1.0.alpha1)
77
libv8 (~> 6.3.0)
88
mini_racer (~> 0.1.15)
99
opal (>= 0.11.0, < 0.12.0)
@@ -13,7 +13,7 @@ PATH
1313
PATH
1414
remote: ../../../hyper-spec
1515
specs:
16-
hyper-spec (1.0.pre.alpha1)
16+
hyper-spec (1.0.alpha1)
1717
capybara
1818
chromedriver-helper (= 1.2.0)
1919
libv8 (~> 6.3.0)
@@ -32,20 +32,20 @@ PATH
3232
PATH
3333
remote: ../../../hyper-state
3434
specs:
35-
hyper-state (1.0.pre.alpha1)
36-
hyperstack-config (= 1.0.pre.alpha1)
35+
hyper-state (1.0.alpha1)
36+
hyperstack-config (= 1.0.alpha1)
3737
opal (>= 0.11.0, < 0.12.0)
3838

3939
PATH
4040
remote: ../../../hyper-trace
4141
specs:
42-
hyper-trace (1.0.pre.alpha1)
43-
hyperstack-config (= 1.0.pre.alpha1)
42+
hyper-trace (1.0.alpha1)
43+
hyperstack-config (= 1.0.alpha1)
4444

4545
PATH
4646
remote: ../../../hyperstack-config
4747
specs:
48-
hyperstack-config (1.0.pre.alpha1)
48+
hyperstack-config (1.0.alpha1)
4949
libv8 (~> 6.3.0)
5050
listen (~> 3.0)
5151
mini_racer (~> 0.1.15)

ruby/hyper-component/lib/hyperstack/internal/component/class_methods.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ module Component
44
# class level methods (macros) for components
55
module ClassMethods
66

7+
def create_element(*params, &children)
8+
ReactWrapper.create_element(self, *params, &children)
9+
end
10+
11+
def insert_element(*params, &children)
12+
RenderingContext.render(self, *params, &children)
13+
end
14+
715
def deprecation_warning(message)
816
Hyperstack.deprecation_warning(self, message)
917
end

ruby/hyper-component/lib/hyperstack/internal/component/tags.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ def included(component)
5959
define_method name do |*params, &children|
6060
RenderingContext.render(component, *params, &children)
6161
end
62-
# handle deprecated _as_node style
63-
define_method "#{name}_as_node" do |*params, &children|
64-
RenderingContext.build_only(component, *params, &children)
65-
end
6662
end
6763
parent.extend(tag_names_module)
6864
end

ruby/hyper-component/spec/client_features/component_spec.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,35 @@ def render
178178
expect_evaluate_ruby('Foo.instance == Foo.instance.force_update!').to be_truthy
179179
end
180180

181+
it 'can buffer an element' do
182+
mount 'Foo' do
183+
class Bar < HyperComponent
184+
param :p
185+
render { DIV { @P.span; children.render } }
186+
end
187+
class Foo < HyperComponent
188+
def render
189+
Bar.insert_element(p: "param") { "child"}
190+
end
191+
end
192+
end
193+
expect(page).to have_content("paramchild")
194+
end
195+
196+
it 'can create an element without buffering' do
197+
mount 'Foo' do
198+
class Bar < HyperComponent
199+
param :p
200+
render { SPAN { @P.span; children.render } }
201+
end
202+
class Foo < HyperComponent
203+
before_mount { @e = Bar.create_element(p: "param") { "child" } }
204+
render { DIV { 2.times { @e.render } } }
205+
end
206+
end
207+
expect(page).to have_content("paramchildparamchild")
208+
end
209+
181210
it 'has a class components method' do
182211
mount 'Foo' do
183212
class Bar < HyperComponent

0 commit comments

Comments
 (0)