phaser-jsx
Version:
Use JSX in Phaser.
30 lines • 927 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createElement = createElement;
/**
* Creates an element.
*
* @param type - The `type` argument must be a valid component type.
* @param props - The `props` argument must either be an object or `null`.
* @param children - Zero or more child elements.
* @returns - Element object with properties `type` and `props`.
*/
function createElement(type, props) {
var children = [];
for (var _i = 2; _i < arguments.length; _i++) {
children[_i - 2] = arguments[_i];
}
props !== null && props !== void 0 ? props : (props = {});
if (children.length) {
props.children = children;
}
if (props.children && !Array.isArray(props.children)) {
props.children = [props.children];
}
return {
type: type,
props: props,
key: null,
};
}
//# sourceMappingURL=create.js.map