UNPKG

747 BJavaScriptView Raw
1import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2var _excluded = ["key", "ref"];
3// 实现jsx-classic 入口
4export function jsx(type, config) {
5 var _ref = config || {},
6 key = _ref.key,
7 ref = _ref.ref,
8 props = _objectWithoutProperties(_ref, _excluded); // 保持和automatic模式一致
9
10
11 for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
12 children[_key - 2] = arguments[_key];
13 }
14
15 if (children.length) {
16 props.children = children.length === 1 ? children[0] : children;
17 }
18
19 return {
20 key: key,
21 ref: ref,
22 type: type,
23 props: props,
24 // 存储一些过程中的cache值
25 _cache: {}
26 };
27}
\No newline at end of file