Problem
The handler_ config in Neo.button.Base was experiencing a bug where, in recycled components (e.g., in a buffered grid), the handler function would become stale. This was due to the default Neo.isEqual (which performs a deep comparison) incorrectly determining that a new handler function (with a new closure) was identical to the old one, preventing the config system from triggering an update.
Solution
The fix involves adding a descriptor to the handler_ config in src/button/Base.mjs. This descriptor overrides the isEqual method to specifically handle function comparisons. If both the old and new handler values are functions, isEqual now returns false, forcing the config system to always treat a new function instance as a change. For other types (e.g., strings), it defaults to strict equality.
Rationale for isEqual override
Standard JavaScript closure behavior means that two function instances, even with identical source code, can close over different variables. The default deep comparison in Neo.isEqual cannot reliably detect this difference. Overriding isEqual ensures that new function instances are always considered a change, preventing stale closures in recycled components.
JSDoc Update
The JSDoc for the handler_ config in src/button/Base.mjs should be updated to explain this behavior and the rationale behind the isEqual override.
Problem
The
handler_config inNeo.button.Basewas experiencing a bug where, in recycled components (e.g., in a buffered grid), the handler function would become stale. This was due to the defaultNeo.isEqual(which performs a deep comparison) incorrectly determining that a new handler function (with a new closure) was identical to the old one, preventing the config system from triggering an update.Solution
The fix involves adding a descriptor to the
handler_config insrc/button/Base.mjs. This descriptor overrides theisEqualmethod to specifically handle function comparisons. If both the old and new handler values are functions,isEqualnow returnsfalse, forcing the config system to always treat a new function instance as a change. For other types (e.g., strings), it defaults to strict equality.Rationale for
isEqualoverrideStandard JavaScript closure behavior means that two function instances, even with identical source code, can close over different variables. The default deep comparison in
Neo.isEqualcannot reliably detect this difference. OverridingisEqualensures that new function instances are always considered a change, preventing stale closures in recycled components.JSDoc Update
The JSDoc for the
handler_config insrc/button/Base.mjsshould be updated to explain this behavior and the rationale behind theisEqualoverride.