mirror of https://gitee.com/antv-l7/antv-l7
28 lines
480 B
JavaScript
28 lines
480 B
JavaScript
'use strict'
|
|
|
|
var assign = require('object-assign')
|
|
|
|
module.exports = u
|
|
|
|
function u(type, props, value) {
|
|
var node
|
|
|
|
if (
|
|
(value === null || value === undefined) &&
|
|
(typeof props !== 'object' || Array.isArray(props))
|
|
) {
|
|
value = props
|
|
props = {}
|
|
}
|
|
|
|
node = assign({type: String(type)}, props)
|
|
|
|
if (Array.isArray(value)) {
|
|
node.children = value
|
|
} else if (value !== null && value !== undefined) {
|
|
node.value = String(value)
|
|
}
|
|
|
|
return node
|
|
}
|