File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
lib/hyperstack/ext/component Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -45,4 +45,16 @@ def self.[](selector)
4545 Element . expose :mount_components
4646end
4747
48+ module Hyperstack
49+ module Internal
50+ module Component
51+ module InstanceMethods
52+ def set_jq ( var )
53+ -> ( val ) { set ( var ) . call ( JQ [ val ] ) }
54+ end
55+ end
56+ end
57+ end
58+ end
59+
4860JQ = Element
Original file line number Diff line number Diff line change @@ -244,6 +244,20 @@ class Foo
244244 expect ( page . body [ -80 ..-19 ] ) . to include ( '<span data-size="12">Hyperstack::Component::Element</span>' )
245245 end
246246
247+ it "has a dom_node method" do
248+ mount 'Foo' do
249+ class Foo
250+ include Hyperstack ::Component
251+ include Hyperstack ::State ::Observable
252+ after_mount { mutate @my_node_id = JQ [ dom_node ] . id }
253+ render do
254+ SPAN ( id : 'foo' ) { "my id is '#{ @my_node_id } '" }
255+ end
256+ end
257+ end
258+ expect ( page ) . to have_content ( "my id is 'foo'" )
259+ end
260+
247261 it "can use the dangerously_set_inner_HTML param" do
248262 mount 'Foo' do
249263 class Foo
Original file line number Diff line number Diff line change @@ -77,4 +77,18 @@ class Foo
7777 end
7878 expect ( page ) . to have_content ( 'I am [object HTMLDivElement]' )
7979 end
80+
81+ it 'can get the a jquery wrapped reference using the set_jq method' do
82+ mount 'Foo' do
83+ class Foo
84+ render do
85+ DIV ( ref : set_jq ( :the_ref ) ) { @the_ref . inspect }
86+ end
87+ after_mount do
88+ force_update!
89+ end
90+ end
91+ end
92+ expect ( page ) . to have_content ( '#<Element [<div>]>' )
93+ end
8094end
You can’t perform that action at this time.
0 commit comments