Refactoring ul/li
This commit is contained in:
parent
0e490fdeee
commit
9f81dfb2f6
|
@ -1,6 +1,7 @@
|
|||
// @flow weak
|
||||
|
||||
import { createElement as h, Component } from 'react'
|
||||
import { Element as ScrollElement } from 'react-scroll'
|
||||
|
||||
import ActionButton from './menu/ActionButton'
|
||||
import AppendActionButton from './menu/AppendActionButton'
|
||||
|
@ -53,26 +54,29 @@ export default class JSONNode extends Component {
|
|||
if (data.expanded) {
|
||||
if (data.props.length > 0) {
|
||||
const props = data.props.map(prop => {
|
||||
return h(this.constructor, {
|
||||
key: prop.name,
|
||||
return h('li', {key : prop.name},
|
||||
h(this.constructor, {
|
||||
parent: this,
|
||||
prop: prop,
|
||||
data: prop.value,
|
||||
options,
|
||||
events
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
contents.push(h('ul', {key: 'props', className: 'jsoneditor-list'}, props))
|
||||
}
|
||||
else {
|
||||
contents.push(h('ul', {key: 'append', className: 'jsoneditor-list'},
|
||||
h('li', {},
|
||||
this.renderAppend('(empty object)')
|
||||
)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
return h('li', {}, contents)
|
||||
return h('div', {}, contents)
|
||||
}
|
||||
|
||||
renderJSONArray ({prop, index, data, options, events}) {
|
||||
|
@ -90,30 +94,32 @@ export default class JSONNode extends Component {
|
|||
if (data.expanded) {
|
||||
if (data.items.length > 0) {
|
||||
const items = data.items.map((child, index) => {
|
||||
return h(this.constructor, {
|
||||
key: index,
|
||||
return h('li', {key : index},
|
||||
h(this.constructor, {
|
||||
parent: this,
|
||||
index,
|
||||
data: child,
|
||||
options,
|
||||
events
|
||||
})
|
||||
)
|
||||
})
|
||||
contents.push(h('ul', {key: 'items', className: 'jsoneditor-list'}, items))
|
||||
}
|
||||
else {
|
||||
contents.push(h('ul', {key: 'append', className: 'jsoneditor-list'},
|
||||
h('li', {},
|
||||
this.renderAppend('(empty array)')
|
||||
)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
return h('li', {}, contents)
|
||||
return h('div', {}, contents)
|
||||
}
|
||||
|
||||
renderJSONValue ({prop, index, data, options}) {
|
||||
return h('li', {},
|
||||
h('div', {className: 'jsoneditor-node'}, [
|
||||
return h('div', {className: 'jsoneditor-node'}, [
|
||||
this.renderPlaceholder(),
|
||||
this.renderActionMenuButton(),
|
||||
this.renderProperty(prop, index, data, options),
|
||||
|
@ -121,7 +127,6 @@ export default class JSONNode extends Component {
|
|||
this.renderValue(data.value, data.searchResult, options),
|
||||
this.renderError(data.error)
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,13 +135,11 @@ export default class JSONNode extends Component {
|
|||
* @return {*}
|
||||
*/
|
||||
renderAppend (text) {
|
||||
return h('li', {key: 'append'},
|
||||
h('div', {className: 'jsoneditor-node'}, [
|
||||
return h('div', {className: 'jsoneditor-node'}, [
|
||||
this.renderPlaceholder(),
|
||||
this.renderAppendMenuButton(),
|
||||
this.renderReadonly(text)
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
renderPlaceholder () {
|
||||
|
|
Loading…
Reference in New Issue