Skip to content

Commit

Permalink
Fix josdejong#969: adding a new property to an empty object or array …
Browse files Browse the repository at this point in the history
…is broken
  • Loading branch information
josdejong committed Apr 22, 2020
1 parent a292b82 commit a68ecf5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
https://github.com/josdejong/jsoneditor


## not yet published, version 8.6.6

- Fix #969: adding a new property to an empty object or array is broken.
Regression introduced in `v8.6.5`.


## 2020-04-19, version 8.6.5

- Fix #964: translation of titles of some context menu items not working.
Expand Down
17 changes: 4 additions & 13 deletions src/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3633,15 +3633,6 @@ export class Node {
*/
showContextMenu (anchor, onClose) {
const node = this

// titles with explanation for the different types
const titles = {
auto: translate('autoType'),
object: translate('objectType'),
array: translate('arrayType'),
string: translate('stringType')
}

let items = []

if (this.editable.value) {
Expand All @@ -3654,7 +3645,7 @@ export class Node {
text: translate('auto'),
className: 'jsoneditor-type-auto' +
(this.type === 'auto' ? ' jsoneditor-selected' : ''),
title: titles.auto,
title: translate('autoType'),
click: function () {
node._onChangeType('auto')
}
Expand All @@ -3663,7 +3654,7 @@ export class Node {
text: translate('array'),
className: 'jsoneditor-type-array' +
(this.type === 'array' ? ' jsoneditor-selected' : ''),
title: titles.array,
title: translate('arrayType'),
click: function () {
node._onChangeType('array')
}
Expand All @@ -3672,7 +3663,7 @@ export class Node {
text: translate('object'),
className: 'jsoneditor-type-object' +
(this.type === 'object' ? ' jsoneditor-selected' : ''),
title: titles.object,
title: translate('objectType'),
click: function () {
node._onChangeType('object')
}
Expand All @@ -3681,7 +3672,7 @@ export class Node {
text: translate('string'),
className: 'jsoneditor-type-string' +
(this.type === 'string' ? ' jsoneditor-selected' : ''),
title: titles.string,
title: translate('stringType'),
click: function () {
node._onChangeType('string')
}
Expand Down
10 changes: 5 additions & 5 deletions src/js/appendNodeFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,36 +146,36 @@ export function appendNodeFactory (Node) {
*/
AppendNode.prototype.showContextMenu = function (anchor, onClose) {
const node = this
const titles = Node.TYPE_TITLES

const appendSubmenu = [
{
text: translate('auto'),
className: 'jsoneditor-type-auto',
title: titles.auto,
title: translate('autoType'),
click: function () {
node._onAppend('', '', 'auto')
}
},
{
text: translate('array'),
className: 'jsoneditor-type-array',
title: titles.array,
title: translate('arrayType'),
click: function () {
node._onAppend('', [])
}
},
{
text: translate('object'),
className: 'jsoneditor-type-object',
title: titles.object,
title: translate('objectType'),
click: function () {
node._onAppend('', {})
}
},
{
text: translate('string'),
className: 'jsoneditor-type-string',
title: titles.string,
title: translate('stringType'),
click: function () {
node._onAppend('', '', 'string')
}
Expand Down

0 comments on commit a68ecf5

Please sign in to comment.