mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Update color handling and enhance session management in the Reconciler
- Added 'Name' to the list of excluded property names in the rbx_dom_lua module to prevent unnecessary comparisons. - Updated color handling in the diff stress tests to use Color3.fromRGB for better precision and clarity in color representation. - Improved the hydrate function to initialize a new session if none is provided, enhancing session management during instance hydration. - Refined the trueEquals function to handle NaN comparisons correctly, ensuring accurate equality checks for numeric values. These changes improve the accuracy of property comparisons and enhance the overall functionality of the Reconciler module.
This commit is contained in:
parent
ddd47b9afa
commit
30e032b27e
5 changed files with 15 additions and 11 deletions
|
|
@ -44,6 +44,7 @@ end
|
||||||
local EXCLUDED_PROP_NAMES: { [string]: boolean } = {
|
local EXCLUDED_PROP_NAMES: { [string]: boolean } = {
|
||||||
Tags = true,
|
Tags = true,
|
||||||
Attributes = true,
|
Attributes = true,
|
||||||
|
Name = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Encoded value type keys that cannot be compared during matching.
|
-- Encoded value type keys that cannot be compared during matching.
|
||||||
|
|
|
||||||
|
|
@ -431,13 +431,13 @@ return function()
|
||||||
|
|
||||||
local part = Instance.new("Part")
|
local part = Instance.new("Part")
|
||||||
part.Name = "TestPart"
|
part.Name = "TestPart"
|
||||||
part.Color = Color3.new(1, 0.5, 0.25)
|
part.Color = Color3.fromRGB(255, 128, 64)
|
||||||
part.Parent = container
|
part.Parent = container
|
||||||
|
|
||||||
local rootId = generateId()
|
local rootId = generateId()
|
||||||
instanceMap:insert(rootId, part)
|
instanceMap:insert(rootId, part)
|
||||||
|
|
||||||
-- Same color values (exact match)
|
-- Same color values (exact 8-bit match avoids quantization mismatch)
|
||||||
local virtualInstances = {
|
local virtualInstances = {
|
||||||
[rootId] = {
|
[rootId] = {
|
||||||
Id = rootId,
|
Id = rootId,
|
||||||
|
|
@ -446,7 +446,7 @@ return function()
|
||||||
Parent = nil,
|
Parent = nil,
|
||||||
Properties = {
|
Properties = {
|
||||||
Color = {
|
Color = {
|
||||||
Color3 = { 1, 0.5, 0.25 },
|
Color3 = { 255 / 255, 128 / 255, 64 / 255 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Children = {},
|
Children = {},
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ local invariant = require(script.Parent.Parent.invariant)
|
||||||
local Matching = require(script.Parent.matching)
|
local Matching = require(script.Parent.matching)
|
||||||
|
|
||||||
local function hydrate(instanceMap, virtualInstances, rootId, rootInstance, session)
|
local function hydrate(instanceMap, virtualInstances, rootId, rootInstance, session)
|
||||||
|
if not session then
|
||||||
|
session = Matching.newSession()
|
||||||
|
end
|
||||||
|
|
||||||
local virtualInstance = virtualInstances[rootId]
|
local virtualInstance = virtualInstances[rootId]
|
||||||
|
|
||||||
if virtualInstance == nil then
|
if virtualInstance == nil then
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,9 @@ local function trueEquals(a: any, b: any): boolean
|
||||||
end
|
end
|
||||||
|
|
||||||
if t == "number" then
|
if t == "number" then
|
||||||
|
if a ~= a then
|
||||||
|
return b ~= b
|
||||||
|
end
|
||||||
return fuzzyEq(a, b)
|
return fuzzyEq(a, b)
|
||||||
end
|
end
|
||||||
if t == "Color3" then
|
if t == "Color3" then
|
||||||
|
|
@ -105,10 +108,6 @@ local function trueEquals(a: any, b: any): boolean
|
||||||
return cframeEq(a, b)
|
return cframeEq(a, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
if a ~= a and b ~= b then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,12 +187,12 @@ return function()
|
||||||
expect(trueEquals(Color3.fromRGB(128, 128, 128), Color3.fromRGB(129, 128, 128))).to.equal(false)
|
expect(trueEquals(Color3.fromRGB(128, 128, 128), Color3.fromRGB(129, 128, 128))).to.equal(false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("near-boundary same floor", function()
|
it("near-boundary within epsilon", function()
|
||||||
expect(trueEquals(Color3.new(128 / 255, 0, 0), Color3.new(128.4 / 255, 0, 0))).to.equal(true)
|
expect(trueEquals(Color3.new(0.5, 0, 0), Color3.new(0.50005, 0, 0))).to.equal(true)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("near-boundary different floor", function()
|
it("near-boundary beyond epsilon", function()
|
||||||
expect(trueEquals(Color3.new(128 / 255, 0, 0), Color3.new(129 / 255, 0, 0))).to.equal(false)
|
expect(trueEquals(Color3.new(0.5, 0, 0), Color3.new(0.502, 0, 0))).to.equal(false)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue