Skip to content

Commit 148c027

Browse files
authored
Fix component kit rendering context (#971)
Closes #960
2 parents cbba67c + 22f0c4b commit 148c027

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

lib/phlex/kit.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def const_added(name)
6363
end
6464

6565
define_singleton_method(name) do |*args, **kwargs, &block|
66-
component, fiber_id = Thread.current[:__phlex_component__]
67-
if (component && fiber_id == Fiber.current.object_id)
66+
component = Thread.current[:__phlex_component__]
67+
if component
6868
component.instance_exec do
6969
constant = me.const_get(name)
7070
render(constant.new(*args, **kwargs), &block)

lib/phlex/sgml.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def internal_call(parent: nil, state: nil, &block)
6060

6161
block ||= @_content_block
6262

63-
Thread.current[:__phlex_component__] = [self, Fiber.current.object_id].freeze
63+
previous_phlex_component = Thread.current[:__phlex_component__]
64+
Thread.current[:__phlex_component__] = self
6465

6566
state.around_render(self) do
6667
before_template(&block)
@@ -82,7 +83,7 @@ def internal_call(parent: nil, state: nil, &block)
8283
after_template(&block)
8384
end
8485
ensure
85-
Thread.current[:__phlex_component__] = [parent, Fiber.current.object_id].freeze
86+
Thread.current[:__phlex_component__] = previous_phlex_component
8687
end
8788

8889
def context

0 commit comments

Comments
 (0)