element refactor - will return to this
This commit is contained in:
@@ -32,6 +32,7 @@ local Element = req("Element")
|
||||
-- externals
|
||||
---@type Animation
|
||||
local Animation = req("Animation")
|
||||
local Transform = Animation.Transform
|
||||
---@type Color
|
||||
local Color = req("Color")
|
||||
---@type Theme
|
||||
@@ -152,8 +153,12 @@ function flexlove.init(config)
|
||||
ScrollManager = ScrollManager,
|
||||
ErrorHandler = flexlove._ErrorHandler,
|
||||
Performance = flexlove._Performance,
|
||||
Transform = Transform,
|
||||
}
|
||||
|
||||
-- Initialize Element module with dependencies
|
||||
Element.init(flexlove._defaultDependencies)
|
||||
|
||||
if config.baseScale then
|
||||
flexlove.baseScale = {
|
||||
width = config.baseScale.width or 1920,
|
||||
@@ -934,7 +939,7 @@ function flexlove.new(props)
|
||||
|
||||
-- If not in immediate mode, use standard Element.new
|
||||
if not flexlove._immediateMode then
|
||||
return Element.new(props, flexlove._defaultDependencies)
|
||||
return Element.new(props)
|
||||
end
|
||||
|
||||
-- Auto-begin frame if not manually started (convenience feature)
|
||||
@@ -959,7 +964,7 @@ function flexlove.new(props)
|
||||
props._scrollX = state._scrollX or 0
|
||||
props._scrollY = state._scrollY or 0
|
||||
|
||||
local element = Element.new(props, flexlove._defaultDependencies)
|
||||
local element = Element.new(props)
|
||||
|
||||
-- Bind persistent state to element (ImmediateModeState)
|
||||
-- Restore event handler state
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1238,12 +1238,15 @@ function TestElementUnhappyPaths:tearDown()
|
||||
end
|
||||
|
||||
-- Test: Element with missing deps parameter
|
||||
function TestElementUnhappyPaths:test_element_without_deps()
|
||||
function TestElementUnhappyPaths:test_element_with_init()
|
||||
-- Test that Element.new() works after FlexLove.init() is called
|
||||
-- Element now uses module-level dependencies initialized via Element.init()
|
||||
FlexLove.init() -- Ensure FlexLove is initialized
|
||||
local Element = require("modules.Element")
|
||||
local success = pcall(function()
|
||||
Element.new({}, nil)
|
||||
Element.new({})
|
||||
end)
|
||||
luaunit.assertFalse(success) -- Should error without deps
|
||||
luaunit.assertTrue(success) -- Should work after Element.init() is called by FlexLove
|
||||
end
|
||||
|
||||
-- Test: Element with negative dimensions
|
||||
|
||||
Reference in New Issue
Block a user