From 30e032b27e90c10cf0a9732aa96398d5e8a6013b Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 18 Feb 2026 06:59:03 -0600 Subject: [PATCH] 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. --- plugin/rbx_dom_lua/init.lua | 1 + plugin/src/Reconciler/diff.stress.spec.lua | 6 +++--- plugin/src/Reconciler/hydrate.lua | 4 ++++ plugin/src/Reconciler/trueEquals.lua | 7 +++---- plugin/src/Reconciler/trueEquals.spec.lua | 8 ++++---- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/plugin/rbx_dom_lua/init.lua b/plugin/rbx_dom_lua/init.lua index c18cf077..321b7b01 100644 --- a/plugin/rbx_dom_lua/init.lua +++ b/plugin/rbx_dom_lua/init.lua @@ -44,6 +44,7 @@ end local EXCLUDED_PROP_NAMES: { [string]: boolean } = { Tags = true, Attributes = true, + Name = true, } -- Encoded value type keys that cannot be compared during matching. diff --git a/plugin/src/Reconciler/diff.stress.spec.lua b/plugin/src/Reconciler/diff.stress.spec.lua index 453787d9..619e55b3 100644 --- a/plugin/src/Reconciler/diff.stress.spec.lua +++ b/plugin/src/Reconciler/diff.stress.spec.lua @@ -431,13 +431,13 @@ return function() local part = Instance.new("Part") part.Name = "TestPart" - part.Color = Color3.new(1, 0.5, 0.25) + part.Color = Color3.fromRGB(255, 128, 64) part.Parent = container local rootId = generateId() instanceMap:insert(rootId, part) - -- Same color values (exact match) + -- Same color values (exact 8-bit match avoids quantization mismatch) local virtualInstances = { [rootId] = { Id = rootId, @@ -446,7 +446,7 @@ return function() Parent = nil, Properties = { Color = { - Color3 = { 1, 0.5, 0.25 }, + Color3 = { 255 / 255, 128 / 255, 64 / 255 }, }, }, Children = {}, diff --git a/plugin/src/Reconciler/hydrate.lua b/plugin/src/Reconciler/hydrate.lua index 0521930f..631c042a 100644 --- a/plugin/src/Reconciler/hydrate.lua +++ b/plugin/src/Reconciler/hydrate.lua @@ -14,6 +14,10 @@ local invariant = require(script.Parent.Parent.invariant) local Matching = require(script.Parent.matching) local function hydrate(instanceMap, virtualInstances, rootId, rootInstance, session) + if not session then + session = Matching.newSession() + end + local virtualInstance = virtualInstances[rootId] if virtualInstance == nil then diff --git a/plugin/src/Reconciler/trueEquals.lua b/plugin/src/Reconciler/trueEquals.lua index 59499f63..54bc70cd 100644 --- a/plugin/src/Reconciler/trueEquals.lua +++ b/plugin/src/Reconciler/trueEquals.lua @@ -90,6 +90,9 @@ local function trueEquals(a: any, b: any): boolean end if t == "number" then + if a ~= a then + return b ~= b + end return fuzzyEq(a, b) end if t == "Color3" then @@ -105,10 +108,6 @@ local function trueEquals(a: any, b: any): boolean return cframeEq(a, b) end - if a ~= a and b ~= b then - return true - end - return false end diff --git a/plugin/src/Reconciler/trueEquals.spec.lua b/plugin/src/Reconciler/trueEquals.spec.lua index 8dccc3db..7ae85138 100644 --- a/plugin/src/Reconciler/trueEquals.spec.lua +++ b/plugin/src/Reconciler/trueEquals.spec.lua @@ -187,12 +187,12 @@ return function() expect(trueEquals(Color3.fromRGB(128, 128, 128), Color3.fromRGB(129, 128, 128))).to.equal(false) end) - it("near-boundary same floor", function() - expect(trueEquals(Color3.new(128 / 255, 0, 0), Color3.new(128.4 / 255, 0, 0))).to.equal(true) + it("near-boundary within epsilon", function() + expect(trueEquals(Color3.new(0.5, 0, 0), Color3.new(0.50005, 0, 0))).to.equal(true) end) - it("near-boundary different floor", function() - expect(trueEquals(Color3.new(128 / 255, 0, 0), Color3.new(129 / 255, 0, 0))).to.equal(false) + it("near-boundary beyond epsilon", function() + expect(trueEquals(Color3.new(0.5, 0, 0), Color3.new(0.502, 0, 0))).to.equal(false) end) end)