Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Allow (and ignore) booleans as children of components (#15)
Browse files Browse the repository at this point in the history
* support booleans in Reconciler
  • Loading branch information
AmaranthineCodices authored and LPGhatguy committed Jan 15, 2018
1 parent 3fd4cff commit f0a9981
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Roact Changelog

## Current master
* No changes
* Support booleans in reconciliation ([#14](https://github.com/Roblox/roact/issues/14))

## 1.0.0 (TODO: Date)
* Initial release
4 changes: 4 additions & 0 deletions lib/Reconciler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ function Reconciler._reifyInternal(element, parent, key, context)
_reifiedChildren = reifiedChildren,
_rbx = target,
}
elseif typeof(element) == "boolean" then
-- Ignore booleans of either value
-- See https://github.com/Roblox/roact/issues/14
return nil
end

error(("Cannot reify invalid Roact element %q"):format(tostring(element)))
Expand Down
8 changes: 8 additions & 0 deletions lib/Reconciler.spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
return function()
local Reconciler = require(script.Parent.Reconciler)

it("should reify booleans as nil", function()
local booleanReified = Reconciler.reify(false)
expect(booleanReified).to.never.be.ok()
end)
end

0 comments on commit f0a9981

Please sign in to comment.