Fixed array/object not being rendered empty when removing the last item
This commit is contained in:
parent
c5a68b1da3
commit
b6d622e0d0
|
@ -71,6 +71,7 @@ export default class JSONNode extends Component {
|
|||
]
|
||||
|
||||
if (data.expanded) {
|
||||
if (data.props.length > 0) {
|
||||
const props = data.props.map(prop => {
|
||||
return h(JSONNode, {
|
||||
parent: this,
|
||||
|
@ -81,11 +82,13 @@ export default class JSONNode extends Component {
|
|||
})
|
||||
})
|
||||
|
||||
if (props.length === 0) {
|
||||
props.push(this.renderAppend('(empty object)'))
|
||||
contents.push(h('ul', {key: 'props', class: 'jsoneditor-list'}, props))
|
||||
}
|
||||
else {
|
||||
contents.push(h('ul', {key: 'append', class: 'jsoneditor-list'}, [
|
||||
this.renderAppend('(empty object)')
|
||||
]))
|
||||
}
|
||||
|
||||
contents.push(h('ul', {class: 'jsoneditor-list'}, props))
|
||||
}
|
||||
|
||||
return h('li', {}, contents)
|
||||
|
@ -103,6 +106,7 @@ export default class JSONNode extends Component {
|
|||
]
|
||||
|
||||
if (data.expanded) {
|
||||
if (data.items.length > 0) {
|
||||
const items = data.items.map((child, index) => {
|
||||
return h(JSONNode, {
|
||||
parent: this,
|
||||
|
@ -112,12 +116,13 @@ export default class JSONNode extends Component {
|
|||
events
|
||||
})
|
||||
})
|
||||
|
||||
if (items.length === 0) {
|
||||
items.push(this.renderAppend('(empty array)'))
|
||||
contents.push(h('ul', {key: 'items', class: 'jsoneditor-list'}, items))
|
||||
}
|
||||
else {
|
||||
contents.push(h('ul', {key: 'append', class: 'jsoneditor-list'}, [
|
||||
this.renderAppend('(empty array)')
|
||||
]))
|
||||
}
|
||||
|
||||
contents.push(h('ul', {class: 'jsoneditor-list'}, items))
|
||||
}
|
||||
|
||||
return h('li', {}, contents)
|
||||
|
@ -141,7 +146,7 @@ export default class JSONNode extends Component {
|
|||
* @return {*}
|
||||
*/
|
||||
renderAppend (text) {
|
||||
return h('li', {}, [
|
||||
return h('li', {key: 'append'}, [
|
||||
h('div', {class: 'jsoneditor-node'}, [
|
||||
this.renderPlaceholder(),
|
||||
this.renderAppendContextMenuButton(),
|
||||
|
|
|
@ -142,7 +142,7 @@ export function append (data, path, type) {
|
|||
* @return {JSONData}
|
||||
*/
|
||||
export function duplicate (data, path, prop) {
|
||||
console.log('duplicate', path)
|
||||
console.log('duplicate', path, prop)
|
||||
|
||||
const dataPath = toDataPath(data, path)
|
||||
const object = getIn(data, dataPath)
|
||||
|
@ -181,7 +181,7 @@ export function duplicate (data, path, prop) {
|
|||
* @return {JSONData}
|
||||
*/
|
||||
export function remove (data, path, prop) {
|
||||
console.log('remove', path)
|
||||
console.log('remove', path, prop)
|
||||
|
||||
const object = getIn(data, toDataPath(data, path))
|
||||
|
||||
|
|
Loading…
Reference in New Issue