From 5aa9d2a1c6aea1defd4dd5664b53647839b3ee26 Mon Sep 17 00:00:00 2001 From: Vladimir Solomatin Date: Wed, 25 Jan 2017 18:12:39 +0300 Subject: [PATCH] Fix a jsoneditor object recreation when there a "modes" or "ace" option There is a === check, which always fails for arrays and objects. When you specify "modes" (array) or "ace" (object) option, this will cause to almost always recreating jsoneditor object. In my case, it lead to empty object showing after mode switching via jsoneditor interface. --- ng-jsoneditor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ng-jsoneditor.js b/ng-jsoneditor.js index b11f9c7..f84cfb9 100644 --- a/ng-jsoneditor.js +++ b/ng-jsoneditor.js @@ -65,6 +65,10 @@ editor.setMode(v); } else if (k === 'name') { editor.setName(v); + } else if (k === 'ace') { + // "ace" object cannot be compared, sorry + } else if (k === 'modes' && angular.toJson(newValue[k]) === angular.toJson(oldValue[k])) { + // "modes" has not been changed } else { //other settings cannot be changed without re-creating the JsonEditor editor = _createEditor(newValue); $scope.updateJsonEditor();