Jemt / Fit.UI

Fit.UI is a JavaScript based UI framework built on Object Oriented principles
http://fitui.org
GNU Lesser General Public License v3.0
19 stars 7 forks source link

Dialog.RemoveButton(..) throws error: Collection was modified while iterating objects #129

Open FlowIT-JIT opened 3 years ago

FlowIT-JIT commented 3 years ago

The following fiddle demonstrates the problem: https://jsfiddle.net/30c8jLk7/3/

Click the button in the dialog to make it remove itself. Dialog.RemoveButton(..) now throws the following error:

Fit.UI.js:1216 Uncaught Error: Collection was modified while iterating objects
    at Object.Fit.Validation.ThrowError (Fit.UI.js:1216)
    at Object.Fit.Array.ForEach (Fit.UI.js:1419)
    at Fit.Controls.Dialog.RemoveButton (Fit.UI.js:14987)
    at ?editor_console=:120
    at Fit.UI.js:11317
    at Object.Fit.Array.ForEach (Fit.UI.js:1416)
    at Fit.Controls.Button.Click (Fit.UI.js:11315)
    at HTMLDivElement.<anonymous> (Fit.UI.js:11093)
FlowIT-JIT commented 3 years ago

Work around: Use Dialog.RemoveAllButtons() and re-add buttons that must remain.