Skip to content

Commit

Permalink
Passed node to mounting to provide access to size operations
Browse files Browse the repository at this point in the history
  • Loading branch information
tredfern committed Jan 28, 2020
1 parent 3bce795 commit d7d731f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion moonpie/ui/render_engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function RenderEngine.build_node(component, parent)
RenderEngine.add_node(RenderEngine.build_node(v, new_node), new_node)
end
end
safecall(component.component_mounted, component)
safecall(new_node.component_mounted, new_node)

return new_node
end
Expand Down
6 changes: 4 additions & 2 deletions moonpie/ui/render_engine_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ describe("RenderEngine", function()
it("calls component_mounted on a component if configured", function()
local param
local c = {
component_mounted = spy.new(function(self) param = self end)
component_mounted = spy.new(function(self) param = self end),
id = 12345
}
RenderEngine("ui", { c })

assert.spy(c.component_mounted).was.called()
assert.equals(param, c)
assert.equals(param.id, c.id)
assert.not_nil(param.box) -- Validating we are actually getting the node
end)

it("sets all the components on the root to children of it", function()
Expand Down

0 comments on commit d7d731f

Please sign in to comment.