@dark-engine/core
Version:
The lightweight and powerful UI rendering engine without dependencies and written in TypeScript (Browser, Node.js, Android, iOS, Windows, Linux, macOS)
42 lines (41 loc) • 1.29 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
exports.Fragment = exports.jsxDEV = exports.jsxs = exports.jsx = void 0;
const utils_1 = require('./utils');
const view_1 = require('./view');
const constants_1 = require('./constants');
const fragment_1 = require('./fragment');
Object.defineProperty(exports, 'Fragment', {
enumerable: true,
get: function () {
return fragment_1.Fragment;
},
});
function jsx(element, props, key) {
const { children, slot: $slot, ...$props } = props;
const content = !(0, utils_1.detectIsUndefined)(children)
? children
: !(0, utils_1.detectIsUndefined)($slot)
? $slot
: [];
const slot = (0, utils_1.detectIsArray)(content) ? content : [content];
if (key || !(0, utils_1.detectIsEmpty)(key)) {
$props[constants_1.KEY_ATTR] = key;
}
if ((0, utils_1.detectIsString)(element)) {
const options = $props || {};
options.as = element;
options.slot = slot;
return (0, view_1.View)(options);
}
if ((0, utils_1.detectIsFunction)(element)) {
const options = $props || {};
options.slot = slot.length === 1 ? slot[0] : slot;
return element(options);
}
return null;
}
exports.jsx = jsx;
exports.jsxs = jsx;
exports.jsxDEV = jsx;
//# sourceMappingURL=jsx-runtime.js.map