Added dirty state check logic to UndoManager.js